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

Readme

Keywords

none

Package Sidebar

Install

npm i file2variable-cli

Weekly Downloads

8

Version

2.0.1

License

MIT

Unpacked Size

17.2 kB

Total Files

8

Last publish

Collaborators

  • plantain_00