file2variable-cli
TypeScript icon, indicating that this package has built-in type declarations

2.0.1 • Public • Published

file2variable-cli

Dependency Status devDependency Status Build Status: Linux Build Status: Windows Github CI npm version Downloads type-coverage

A CLI tool to read file content and assign it to a variable

features

  • file content as string variable (*)
  • json file content as object variable (*.json --json)
  • protobuf file content as object variable (*.proto --protobuf)
  • html file minified (*.html --html-minify)
  • vue3 template precompile (* --vue3)
  • position for html file and vue template(<div data-_position="demo/baz.html:2:5"></div>)

install

npm i file2variable-cli

usage

file2variable-cli demo/*.html demo/*.json demo/*.proto -o demo/variables.js --html-minify --json --protobuf --base demo

file2variable-cli demo/*.html demo/*.json demo/*.proto -o demo/variables.js --html-minify --json --protobuf --base demo --watch

options

key description
--config config file
-w,--watch watch mode
-h,--help Print this message.
-v,--version Print the version

config file

file2variable-cli --config demo/file2variable.config.js or file2variable-cli --config demo/file2variable.config.ts

import { Configuration } from 'file2variable-cli'

module.exports = {
  base: 'demo',
  files: [
    'demo/*.txt',
    'demo/*.html',
    'demo/*.json',
    'demo/*.proto'
  ],
  handler: file => {
    if (file.endsWith('foo.html')) {
      return {
        type: 'vue3',
      }
    }
    if (file.endsWith('baz.html')) {
      return { type: 'html-minify' }
    }
    if (file.endsWith('.json')) {
      return { type: 'json' }
    }
    if (file.endsWith('.proto')) {
      return { type: 'protobuf' }
    }
    return { type: 'text' }
  },
  out: 'demo/variables.ts'
} as Configuration

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
2.0.15latest

Version History

VersionDownloads (Last 7 Days)Published
2.0.15
2.0.00
1.13.30
1.13.20
1.13.10
1.13.00
1.12.20
1.12.10
1.12.00
1.11.00
1.10.10
1.10.00
1.9.20
1.9.10
1.9.00
1.8.50
1.8.40
1.8.30
1.8.20
1.8.10
1.8.00
1.7.50
1.7.40
1.7.30
1.7.20
1.7.10
1.7.00
1.6.00
1.5.41
1.5.20
1.5.10
1.5.00
1.4.10
1.4.00
1.3.00
1.2.10
1.2.00
1.1.00
1.0.00

Package Sidebar

Install

npm i file2variable-cli

Weekly Downloads

3

Version

2.0.1

License

MIT

Unpacked Size

17.2 kB

Total Files

8

Last publish

Collaborators

  • plantain_00