file2variable-cli
v2.0.1
Published
A CLI tool to read file content and assign it to a variable
Downloads
19
Readme
file2variable-cli
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