2.0.3 • Published 7 years ago

apprc v2.0.3

Weekly downloads
5
License
MIT
Repository
github
Last release
7 years ago

apprc

build status npm version npm downloads npm dependencies

My opinionated and almost-non-configurable configuration loader for lazy people who like yaml.

  • 1 file for multible environments
  • supports yaml or json
  • deep-freezes config object

Installation

yarn add apprc

Usage

apprc will look for config files in the following locations:

  • closest .${appName}rc by continuously looking in '../' until '/' is reached
  • $HOME/.${appName}rc
  • $HOME/${appName}/config
  • $HOME/.${appName}/config
  • $HOME/.config/${appName}rc
  • $HOME/.config/${appName}/config
  • /etc/${appName}rc
  • /etc/${appName}/config

files can optionally have the .yml or .json extension in their names

Module

const config = require('apprc')(defaults, envKey, appName)

arguments default to:

defaults = {}
appName = package_json.name
envKey = process.env.NODE_ENV || 'development'

CLI

$ apprc --help

apprc <variable> [args]

Options:
  --env, -e        Environment                               [string] [required]
  --name, -n       Name (default: "name" in package.json)               [string]
  --force, -f      Don't bail on missing value                         [boolean]
  --undefined, -u  Fallback output of missing value                     [string]
  --delimiter, -d  Custom path delimiter (default: ".")  [string] [default: "."]
  --help, -h, -?   Show help                                           [boolean]


$ apprc --env production
{"http":{"port":80}}

$ apprc http --env production
{"port":80}

$ apprc http.port --env production
80

Config Format

Config files must be in the JSON or YAML format:

---
defaults:
    view_engine: jade

development:
    http_port: 8080

production:
    http_port: 80

loaded with:

const config = require('apprc')('development')

results in:

{
    "view_engine": "jade",
    "http_port": 8080
}

LICENSE

MIT

2.0.3

7 years ago

2.0.2

7 years ago

2.0.1

7 years ago

2.0.0

7 years ago

1.3.0

7 years ago

1.2.1

7 years ago

1.2.0

7 years ago

1.1.0

7 years ago

1.0.1

8 years ago

1.0.0

8 years ago