Finds and loads runtime-configuration file for the current project, with precedence.
npm i rcfy
# or
yarn add rcfy
This package is pure ESM, please read the esm-package.
import { findRc, loadRc } from 'rcfy'
const rcFile = await findRc('myproject')
// => root/to/project/.myproject.js
const rc = await loadRc('myproject')
// => { ... }
▸ findRc(name
, cwd?
): Promise
<string
| undefined
>
Finds runtime-configuration file.
import { findRc } from 'rcfy'
const rcFile = await findRc('myproject', './config')
// will finds:
// - `.myprojectrc` file in the `./config` directory.
// - `.myprojectrc.json` file in the `./config` directory.
// - `.myprojectrc.{yaml,yml}` file in the `./config` directory.
// - `.myproject.{mjs,cjs,js}` file in the `./config` directory.
// - `myproject.config.{mjs,cjs,js}` file in the `./config` directory.
Name | Type |
---|---|
name |
string |
cwd |
string |
Promise
<string
| undefined
>
▸ loadRc<T
= any
>(name
, cwd?
, ...args
): Promise
<T
>
Loads runtime-configuration file, with precedence.
import { loadRc } from 'rcfy'
const rc = await loadRc('myproject')
// will try to loads config from:
// - `myproject` field in the `package.json` file.
// - `.myprojectrc` file in the `cwd`.
// - `.myprojectrc.json` file in the `cwd`.
// - `.myprojectrc.{yaml,yml}` file in the `cwd`.
// - `.myproject.{mjs,cjs,js}` file in the `cwd`.
// - `myproject.config.{mjs,cjs,js}` file in the `cwd`.
Note: Config that found in the package.json
will be merged with
higher precedence.
Name | Type |
---|---|
name |
string |
cwd |
string |
...args |
any [] |
Promise
<T
>
▸ findRcSync(name
, cwd?
): string
| undefined
Finds runtime-configuration file synchronously.
import { findRcSync } from 'rcfy'
const rcFile = findRcSync('myproject', './config')
// will finds:
// - `.myprojectrc` file in the `./config` directory.
// - `.myprojectrc.json` file in the `./config` directory.
// - `.myprojectrc.{yaml,yml}` file in the `./config` directory.
// - `.myproject.{cjs,js}` file in the `./config` directory.
// - `myproject.config.{cjs,js}` file in the `./config` directory.
Name | Type |
---|---|
name |
string |
cwd |
string |
string
| undefined
▸ loadRcSync<T
= any
>(name
, cwd?
, ...args
): T
| Promise
<T
>
Loads runtime-configuration file synchronously, with precedence.
import { loadRcSync } from 'rcfy'
const rc = loadRcSync('myproject')
// will try to loads config from:
// - `myproject` field in the `package.json` file.
// - `.myprojectrc` file in the `cwd`.
// - `.myprojectrc.json` file in the `cwd`.
// - `.myprojectrc.{yaml,yml}` file in the `cwd`.
// - `.myproject.{cjs,js}` file in the `cwd`.
// - `myproject.config.{cjs,js}` file in the `cwd`.
Note: Config that found in the package.json
will be merged with
higher precedence.
Name | Type |
---|---|
name |
string |
cwd |
string |
...args |
any [] |
T
| Promise
<T
>
-
loadee
– A utility to simplify the loading of YAML, JSON, and JS files.
We 💛 issues.
When committing, please conform to the semantic-release commit standards. Please install commitizen
and the adapter globally, if you have not already.
npm i -g commitizen cz-conventional-changelog
Now you can use git cz
or just cz
instead of git commit
when committing. You can also use git-cz
, which is an alias for cz
.
git add . && git cz
A project by Stilearning © 2022-2024.