# apprc

> opinionated and non-configurable config loader for lazy people who like yaml

Latest version **2.0.3** (published 2017-05-29) · MIT license · 0 weekly downloads

## Install

```sh
npm install apprc
pnpm add apprc
yarn add apprc
bun add apprc
```

Provides the command `apprc`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.3 |
| Published | 2017-05-29 |
| First published | 2016-07-11 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 5 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Richard Keil |
| Maintainers | igl |

## Links

- npm: https://www.npmjs.com/package/apprc
- Repository: https://github.com/igl/apprc
- Homepage: https://github.com/igl/apprc#readme
- Issues: https://github.com/igl/apprc/issues
- npm.io page: https://npm.io/package/apprc

## Dependencies (5)

- [yargs](https://npm.io/package/yargs.md) ^8.0.1
- [js-yaml](https://npm.io/package/js-yaml.md) ^3.8.4
- [os-homedir](https://npm.io/package/os-homedir.md) 1.0.2
- [deep-extend](https://npm.io/package/deep-extend.md) ^0.5.0
- [deep-freeze](https://npm.io/package/deep-freeze.md) 0.0.1

## Recent versions

- 2.0.3 (latest) — 2017-05-29
- 2.0.2 — 2017-05-29
- 2.0.1 — 2017-05-26
- 2.0.0 — 2017-05-26
- 1.3.0 — 2017-05-10
- 1.2.1 — 2017-05-10
- 1.2.0 — 2017-05-10
- 1.1.0 — 2016-10-27
- 1.0.1 — 2016-07-20
- 1.0.0 — 2016-07-11

## README

# apprc

[![build status](https://travis-ci.org/igl/apprc.svg?branch=master)](https://travis-ci.org/igl/apprc)
[![npm version](https://img.shields.io/npm/v/apprc.svg?style=flat)](https://www.npmjs.com/package/apprc)
[![npm downloads](https://img.shields.io/npm/dm/apprc.svg?style=flat)](https://www.npmjs.com/package/apprc)
[![npm dependencies](https://david-dm.org/igl/apprc.svg?style=flat)](https://david-dm.org/igl/apprc)


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

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

arguments default to:

```javascript
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:

```yaml
---
defaults:
    view_engine: jade

development:
    http_port: 8080

production:
    http_port: 80
```

loaded with:

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

```

results in:

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

## LICENSE

MIT

---
_Source: https://npm.io/package/apprc · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
