2.0.1 • Published 3 years ago

file2variable-cli v2.0.1

Weekly downloads
42
License
MIT
Repository
github
Last release
3 years ago

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

keydescription
--configconfig file
-w,--watchwatch mode
-h,--helpPrint this message.
-v,--versionPrint 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
2.0.1

3 years ago

2.0.0

4 years ago

1.13.3

4 years ago

1.13.2

4 years ago

1.13.1

4 years ago

1.13.0

4 years ago

1.12.2

4 years ago

1.12.1

4 years ago

1.12.0

4 years ago

1.11.0

4 years ago

1.10.1

4 years ago

1.10.0

4 years ago

1.9.2

4 years ago

1.9.1

4 years ago

1.9.0

5 years ago

1.8.5

6 years ago

1.8.4

6 years ago

1.8.3

6 years ago

1.8.2

6 years ago

1.8.1

6 years ago

1.8.0

6 years ago

1.7.5

6 years ago

1.7.4

6 years ago

1.7.3

6 years ago

1.7.2

6 years ago

1.7.1

6 years ago

1.7.0

6 years ago

1.6.0

7 years ago

1.5.4

7 years ago

1.5.2

7 years ago

1.5.1

7 years ago

1.5.0

7 years ago

1.4.1

7 years ago

1.4.0

7 years ago

1.3.0

7 years ago

1.2.1

7 years ago

1.2.0

7 years ago

1.1.0

7 years ago

1.0.0

7 years ago