chen.js
v2.1.1
Published
![Cheeen~](./img/chen.png)
Downloads
25
Readme
Chen.js :smiley_cat:
:smiley_cat: Node.JS tool to parse cli arguments, enviroment variables and load configs from .js files
CLI arguments parser
// Called with args:
// --prop 100 --flag -abc input output --type="pdf document" -- "more unnamed args" -not-a-a-flag
require('chen.js').args();
/**
{
_: ['input', 'output', 'more unnamed args', '-not-a-a-flag'],
prop: 100,
flag: true,
a: true,
b: true,
c: true,
type: 'pdf document',
}
**/
Config loader
/**
* Loads `${PWD}/.config.js` by default
*/
const config = require('chen.js').config();
/**
* Loads `${PWD}/.cfg.js`
*/
const config = require('chen.js').config('.cfg.js');
/**
* Loads `${PWD}/.config.js`
* Loads `${PWD}/.config.dev.js` and overrides previous config
*/
const config = require('chen.js').config(['.config.js', '.config.dev.js']);
/**
* Assuming called with CLI args: --config=.config.dev.js
* Loads `${PWD}/.config.js`
* Loads `${PWD}/.config.dev.js` and overrides previous config
*/
const config = require('chen.js').config();
/**
* Assuming called with CLI args: --config=.config.dev.js --config=.config.dev2.js
* Loads `${PWD}/.config.js`
* Loads `${PWD}/.config.dev.js` and overrides previous config
* Loads `${PWD}/.config.dev2.js` and overrides previous config
*/
const config = require('chen.js').config();
Env parser
Loads and parses environment variables and .env files (via dotenv package).
const env = require('chen').env();