# manis

> Find and read your configuration files recursively

Latest version **0.3.5** (published 2019-05-15) · MIT license · 0 weekly downloads

## Install

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

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.3.5 |
| Published | 2019-05-15 |
| First published | 2015-07-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=4 |
| Dependencies | 2 |
| Unpacked size | 22.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 4 |
| Author | chris |
| Maintainers | ecomfe-core |
| Keywords | config, loader, rcloader, json, yaml |

## Links

- npm: https://www.npmjs.com/package/manis
- Repository: https://github.com/ecomfe/manis
- Issues: https://github.com/ecomfe/manis/issues
- npm.io page: https://npm.io/package/manis

## Dependencies (2)

- [js-yaml](https://npm.io/package/js-yaml.md) ^3.5.1
- [strip-json-comments](https://npm.io/package/strip-json-comments.md) ^2.0.0

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 0.3.5 (latest) — 2019-05-15
- 0.3.1 (stable) — 2016-10-03
- 0.3.4 — 2018-07-31
- 0.3.3 — 2018-07-27
- 0.3.2 — 2018-07-04
- 0.3.0 — 2016-01-25
- 0.3.0-beta.2 — 2016-01-25
- 0.3.0-beta.1 — 2016-01-11
- 0.2.3 — 2015-10-29
- 0.2.1 — 2015-10-20
- 0.2.0 — 2015-10-19
- 0.1.1 — 2015-10-14
- 0.1.0 — 2015-07-22

## README

Manis
==========

For build system plugins that need to fetch relative config files (like .fecsrc).



[![Build Status](https://img.shields.io/travis/ecomfe/manis.svg?style=flat)](http://travis-ci.org/ecomfe/manis)
[![NPM version](https://img.shields.io/npm/v/manis.svg?style=flat)](https://www.npmjs.com/package/manis)
[![Coverage Status](https://img.shields.io/coveralls/ecomfe/manis.svg?style=flat)](https://coveralls.io/r/ecomfe/manis)
[![DevDependencies](https://img.shields.io/david/dev/ecomfe/manis.svg?style=flat)](https://david-dm.org/ecomfe/manis)

## Install

```sh
npm install manis
```


## Usage

### Using `strip-json-comments`

```javascript
var Manis = require('manis');
var stripJSONComments = require('strip-json-comments');

var loader = function (text) {
    return JSON.parse(stripJSONComments(text));
};

var manis = new Manis({
    files: [
        {
            // just for example, it should be loaded as yaml in fact.
            name: '.eslintrc',
            get: function (json) {
                return {eslint: json};
            }
        },
        '.fecsrc',
        {
            name: 'package.json',
            get: function (json) {
                return json.fecs || {};
            }
        }
    ],
    loader: loader
});

var options = manis.from('path/to/file.js');

// do something cool with options
```

#### NOTICE: the default loader strip comment after manis@0.3.0.

### Loading `.yml` with `js-yaml`

```javascript
var yaml = require('js-yaml');

var Manis = require('manis');

var loader = function (text) {
    return yaml.load(text);
};

var manis = new Manis('.travis.yml', {loader: loader});

var options = manis.from('path/to/file.js');

// do something cool with options
```

#### NOTICE: the default loader used `js-yaml` to load YAML and JSON content after manis@0.3.0.


### With defaults

```javascript
var Manis = require('manis');

var manis = new Manis({
    files: [
        '.fecsrc',
        {
            name: 'package.json',
            get: 'fecs'
        }
    ]
});

manis.setDefault('default/path/to/config/fecs.json');

var options = manis.from('path/to/file.js');

// do something cool with options
```


### User config

```javascript
var Manis = require('manis');

var manis = new Manis({
    files: [
        '.fecsrc',
        {
            name: 'package.json',
            get: 'fecs'
        }
    ]
});

manis.setDefault('default/path/to/config/fecs.json');

// will find `~/.fecsrc`
manis.setUserConfig();

var options = manis.from('path/to/file.js');

// do something cool with options
```


### Within a gulp plugin

```javascript
var Manis = require('manis');
var map = require('map-stream');

module.exports = function MyGulpPlugin(options) {
    var manis = new Manis('.fecsrc', options);

    return map(function (file, cb) {

        // get the options for this file specifically
        var options = manis.from(file.path);

        // do something cool

        // send the file along
        cb(null, file);

    });
};
```


## API

### new Manis(string fileName[, Object options]);
### new Manis(string[] fileNames[, Object options]);
### new Manis(Object[] finderOptioins[, Object options]);
### new Manis(Object options);

### void Manis#setDefault(Object defaultValue);
### void Manis#setDefault(string filePath[, Object finderOptions]);

### void Manis#setUserConfig();
### void Manis#setUserConfig(Object userConfig);
### void Manis#setUserConfig(string userConfigPathOrName[, Object finderOptions]);

### Object Manis#from(string path);

### Manis.yaml;

Alias for `js-yaml` module.

### Object Manis.loader;

The default loader, parse JSON or YAML content with `js-yaml`.


### Object Manis#from(string path);

#### options

 - `files`, Array or string, items could be string or Object.

 - `loader`, Function，parser for config content.

 - `lookup`, Boolean, Find all up-level config files. default is true.

 - `merge`, Boolean, Merge all config objects. default is true.

 - `cache`, Boolean, Cache config files. default is true.

 - `rootName`, String, The name of flag when `enableRoot` set to true. default is 'root'.

 - `enableRoot`, Boolean, Enable the root flag to stop lookup in up-level directory. default is false.

 - `stopper`, Function, the predicate for stopping search. default is null.

#### finderOptions

 - `name`, string, the file name to be searched.

 - `loader`, Funtion, the same as options.loader above;

 - `stopper`, Function, the predicate for stopping search.

 - `get`, string or Function, the field name to retrieve from config object.

 - `cache`, Boolean, Cache config files. default is true.

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