0.1.0 • Published 2 years ago

c11 v0.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

c11

npm version npm downloads Github Actions Codecov

Smart Config Loader

Features

Usage

Install package:

# npm
npm install c11

# yarn
yarn install c11

# pnpm
pnpm install c11

Import:

// ESM
import { loadConfig } from 'c11'

// CommonJS
const { loadConfig } = require('c11')

Load configuration:

const { config } = await loadConfig({})

Loading priority

c11 merged config sources with unjs/defu by below order:

  1. config overrides passed by options
  2. config file in CWD
  3. RC file in CWD
  4. global RC file in user's home directory
  5. default config passed by options

Options

cwd

Resolve configuration from this working directory. Default is process.cwd()

name

Configuration base name. Default is config.

configName

Configuration file name without extension . Default is generated from name (name=foo => foo.config).

Set to false to avoid loading config file.

rcFile

RC Config file name. Default is generated from name (name=foo => .foorc).

Set to false to disable loading RC config.

globalRC

Load RC config from the user's home directory. Only enabled when rcFile is provided. Set to false to disable this functionality.

dotenv

Loads .env file if enabled. It is disabled by default.

defaults

Specify default configuration. It has the lowest priority.

overides

Specify override configuration. It has the highest priority.

💻 Development

  • Clone this repository
  • Enable Corepack using corepack enable (use npm i -g corepack for Node.js < 16.10)
  • Install dependencies using yarn install
  • Run interactive tests using yarn dev

License

Made with 💛 Published under MIT License.