0.1.4 • Published 6 years ago
tomlrc v0.1.4
tomlrc
Search for and load TOML configuration files.
tomlrc
is like cosmiconfig
, but only searches for TOML files.
Install
npm install tomlrc
Usage
# .unicornrc
envs = ["ava"]
globals = ["graphql"]
extends = "xo"
[rules]
"unicorn/filename-case" = "off"
"import/newline-after-import" = "off"
prefer-const = "error"
const tomlrc = require("tomlrc");
const config = tomlrc("unicorn");
console.log(config);
/*
{
"rules": {
"unicorn/filename-case": "off",
"import/newline-after-import": "off",
"prefer-const": "error"
},
"envs": [
"ava"
],
"globals": [
"graphql"
],
"extends": "xo"
}
*/
API
tomlrc(namespace: string, cwd?: string): Object
cwd
is the directory to start searching up from.
The following files will be searched for, according to the passed-in namespace
:
[
".{nameSpace}rc",
".{nameSpace}rc.toml",
"{nameSpace}rc",
"{nameSpace}rc.toml"
]
If no tomlrc
file is found, an empty object {}
is returned.
If a namespace
is not passed it, an Error
will be thrown.