Skip to content
Search for and load TOML configuration files.
JavaScript
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.dependabot
.github/workflows
fixtures
src
.editorconfig
.eslintrc
.gitignore
.prettierrc
.releaserc
README.md
jest.confg.json
package.json
tsconfig.json
yarn.lock

README.md

tomlrc

Search for and load TOML configuration files.

tomlrc is like cosmiconfig, but only searches for TOML files.

Install

yarn add 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.

License

MIT © Jorge Gonzalez

You can’t perform that action at this time.