Skip to content
This repository has been archived by the owner on Jun 1, 2020. It is now read-only.

jajaperson/js2json

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

js2json NPM Version Build Status

Easily use JavaScript for configuration files to be converted to JSON.

Usage

First, install the package

Globally

npm install -g @jajaperson/js2json

Locally (recommended if you are using js2json in your build step)

npm install --save-dev @jajaperson/js2json

Then, run the command like so

js2json --input example.json.js

You can also use --output to specify the output path

js2json --input example.json.js --output my-new-json-file.json

Advanced options

$ js2json --help
--input <input file> [args]

Options:
  --version, -v   Show version number                                  [boolean]
  -i, --input     js file to convert                         [string] [required]
  -o, --output    json file to output           [string] [default: <input>.json]
  -p, --pretty    format the json output                               [boolean]
  --sp, --spaces  number of spaces to use for indentation  [number] [default: 2]
  --help, -h      Show help                                            [boolean]

Use Cases

If you want to include dynamic values in a JSON configuration file, you can use a javascript file that module.exports the object and add js2json to your build step.

About

Easily use JavaScript for configuration files to be converted to JSON

Resources

License

Stars

Watchers

Forks

Packages

No packages published