Skip to content

😺 Node.JS tool to parse cli arguments, enviroment variables and load configs from .js files

Notifications You must be signed in to change notification settings

kotborealis/chen

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

59 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cheeen~

Chen.js 😺

😺 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();

About

😺 Node.JS tool to parse cli arguments, enviroment variables and load configs from .js files

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published