Manis
For build system plugins that need to fetch relative config files (like .fecsrc).
Install
npm install manis
Usage
strip-json-comments
Using var Manis = ;var stripJSONComments = ; var { return JSON;}; var manis = files: // just for example, it should be loaded as yaml in fact. name: '.eslintrc' { return eslint: json; } '.fecsrc' name: 'package.json' { return jsonfecs || {}; } loader: loader; var options = manis; // do something cool with options
NOTICE: the default loader strip comment after manis@0.3.0.
.yml
with js-yaml
Loading var yaml = ; var Manis = ; var { return yaml;}; var manis = '.travis.yml' loader: loader; var options = manis; // do something cool with options
js-yaml
to load YAML and JSON content after manis@0.3.0.
NOTICE: the default loader used With defaults
var Manis = ; var manis = files: '.fecsrc' name: 'package.json' get: 'fecs' ; manis; var options = manis; // do something cool with options
User config
var Manis = ; var manis = files: '.fecsrc' name: 'package.json' get: 'fecs' ; manis; // will find `~/.fecsrc`manis; var options = manis; // do something cool with options
Within a gulp plugin
var Manis = ;var map = ; module { var manis = '.fecsrc' options; return ;};
API
new Manis(string fileName[, Object options]);
new Manis(string[] fileNames[, Object options]);
new Manis(Object[] finderOptioins[, Object options]);
new Manis(Object options);
void Manis#setDefault(Object defaultValue);
void Manis#setDefault(string filePath[, Object finderOptions]);
void Manis#setUserConfig();
void Manis#setUserConfig(Object userConfig);
void Manis#setUserConfig(string userConfigPathOrName[, Object finderOptions]);
Object Manis#from(string path);
Manis.yaml;
Alias for js-yaml
module.
Object Manis.loader;
The default loader, parse JSON or YAML content with js-yaml
.
Object Manis#from(string path);
options
-
files
, Array or string, items could be string or Object. -
loader
, Function,parser for config content. -
lookup
, Boolean, Find all up-level config files. default is true. -
merge
, Boolean, Merge all config objects. default is true. -
cache
, Boolean, Cache config files. default is true. -
rootName
, String, The name of flag whenenableRoot
set to true. default is 'root'. -
enableRoot
, Boolean, Enable the root flag to stop lookup in up-level directory. default is false. -
stopper
, Function, the predicate for stopping search. default is null.
finderOptions
-
name
, string, the file name to be searched. -
loader
, Funtion, the same as options.loader above; -
stopper
, Function, the predicate for stopping search. -
get
, string or Function, the field name to retrieve from config object. -
cache
, Boolean, Cache config files. default is true.