# @blinkmobile/blinkmrc

> bit like https://github.com/yeoman/configstore but with home-directory and project-specific files

Latest version **2.0.0** (published 2018-07-20) · BSD-3-Clause license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install @blinkmobile/blinkmrc
pnpm add @blinkmobile/blinkmrc
yarn add @blinkmobile/blinkmrc
bun add @blinkmobile/blinkmrc
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2018-07-20 |
| First published | 2016-02-19 |
| Weekly downloads | 0 |
| License | BSD-3-Clause |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=6.0.0 |
| Dependencies | 3 |
| Unpacked size | 12 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Ron Waldon |
| Maintainers | blinkmobile-admin, kizaonline, mymattcarroll, simon_marklar |

## Links

- npm: https://www.npmjs.com/package/@blinkmobile/blinkmrc
- Repository: https://github.com/blinkmobile/blinkmrc.js
- Homepage: https://github.com/blinkmobile/blinkmrc.js#readme
- Issues: https://github.com/blinkmobile/blinkmrc.js/issues
- npm.io page: https://npm.io/package/@blinkmobile/blinkmrc

## Dependencies (3)

- [appdirectory](https://npm.io/package/appdirectory.md) 0.1.0
- [load-json-file](https://npm.io/package/load-json-file.md) ^4.0.0
- [write-json-file](https://npm.io/package/write-json-file.md) 2.3.0

## Recent versions

- 2.0.0 (latest) — 2018-07-20
- 1.1.0 — 2016-02-19
- 1.0.0 — 2016-02-19

## README

# blinkmrc.j [![npm module](https://img.shields.io/npm/v/@blinkmobile/blinkmrc.svg)](https://www.npmjs.com/package/@blinkmobile/blinkmrc) [![Travis CI Status](https://travis-ci.org/blinkmobile/blinkmrc.js.svg?branch=master)](https://travis-ci.org/blinkmobile/blinkmrc.js) [![AppVeyor Status](https://img.shields.io/appveyor/ci/blinkmobile/blinkmrc-js/master.svg)](https://ci.appveyor.com/project/blinkmobile/blinkmrc-js) [![Greenkeeper badge](https://badges.greenkeeper.io/blinkmobile/blinkmrc.js.svg)](https://greenkeeper.io/)

bit like https://github.com/yeoman/configstore but with home-directory and project-specific files

We extracted this from [blinkmobile/bmp-cli](https://github.com/blinkmobile/bmp-cli) for the benefit of our other CLI projects.


## What is this?

This is a basic configuration file management library, hardcoded with defaults that suit our purposes. Like [git](http://git-scm.com/) and [npm](https://www.npmjs.com/package/npm), this library straddles configuration files in 2 locations:

- your home directory (based on your operating system), where files are readable by the current user and inaccessible by other users

- your project directory, where files are readable by anyone with access to the project (i.e. if you version control these files with your project)

This pair of configuration files are both JSON-formatted.

By default we use the following filenames (but this is configurable):

- user: blinkmrc.json

- project: .blinkmrc.json (like .eslintrc.json or .travis.yml)


## API

```js
const blinkmrc = require('@blinkmobile/blinkmrc');
const pkg = require('./package.json');
```


### `userConfig (options: ConfigOptions) => ConfigStore`

```js
const userConfig = blinkmrc.userConfig({ name: pkg.name, /* ... */ });
```


#### UserConfigOptions

```
interface ConfigOptions {
  fileMode = 0o600: Number,
  userConfigDir?: String,
...ConfigOptions
}
```


### `project (options: ConfigOptions) => ConfigStore`

```js
const projectConfig = blinkmrc.projectConfig({ name: pkg.name, /* ... */ });
```


#### ProjectConfigOptions

```
interface ConfigOptions {
  cwd = process.cwd(): String,
  fileMode = 0o666: Number,
  ...ConfigOptions
}
```


### ConfigOptions

```
interface ConfigOptions {
  name: String,
  filename = 'blinkmrc.json': String,
  fileMode?: Number
}
```


### ConfigStore

```
interface ConfigStore {
  load () => Promise[Object],
  update (updater: UpdaterFunction) => Promise,
  write () => Promise
}
```


#### `load () => Promise[Object]`

Locate the configuration file.
If found, parse it as JSON and return the Object.
If not found:

- userConfig: return a new Object

- projectConfig: reject with an Error


#### `update (updater: UpdaterFunction) => Promise[Object]`

Load the configuration data as above.
Then pass it to the provided UpdaterFunction.
Write the result of the UpdaterFunction back to the configuration file.


##### UpdaterFunction (config: Object) => Object

This function receives the current configuration data.
This function may or may not change this data (as you determine) before returning it.


#### `write (config: Object) => Promise[Object]`

Store the provided configuration data in the appropriate file.

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