# rcloader

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

Latest version **0.2.2** (published 2016-11-14) · MIT license · 0 weekly downloads

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

## Install

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

## Health

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

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 0.2.2 |
| Published | 2016-11-14 |
| First published | 2014-02-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/rcloader) |
| Module format | CommonJS |
| Node | >= 0.10 |
| Dependencies | 4 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 13 |
| Author | Spencer Alger |
| Maintainers | spalger |
| Keywords | find, rcfile, rc, search, defaults, config |

## Links

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

## Dependencies (4)

- [rcfinder](https://npm.io/package/rcfinder.md) ^0.1.6
- [lodash.merge](https://npm.io/package/lodash.merge.md) ^4.6.0
- [lodash.assign](https://npm.io/package/lodash.assign.md) ^4.2.0
- [lodash.isobject](https://npm.io/package/lodash.isobject.md) ^3.0.2

## Alternatives

- [jsforce](https://npm.io/package/jsforce.md) — 851.2K weekly downloads
- [react-native-qrcode-svg](https://npm.io/package/react-native-qrcode-svg.md) — 693.5K weekly downloads
- [@salesforce/plugin-data](https://npm.io/package/@salesforce/plugin-data.md) — 394.9K weekly downloads
- [@backstage/plugin-search-common](https://npm.io/package/@backstage/plugin-search-common.md) — 308.5K weekly downloads
- [@chain-registry/types](https://npm.io/package/@chain-registry/types.md) — 38.4K weekly downloads

## Recent versions

- 0.2.2 (latest) — 2016-11-14
- 0.2.1 — 2016-05-09
- 0.2.0 — 2016-01-10
- 0.1.4 — 2015-02-01
- 0.1.2 — 2014-03-31
- 0.1.1 — 2014-02-18
- 0.1.0 — 2014-02-18
- 0.0.1 — 2014-02-18

## README

# rcloader

[![Travis CI](https://travis-ci.org/spalger/rcloader.svg)](https://travis-ci.org/spalger/rcloader)

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

## Features
  - Find the closest config file (like .jshintrc) relative to the file you are linting
  - Lookups are cached to limit IO operations
  - Accepts input directly from plugin consumers to
    - specifiy a file that should always be used
    - specify a default file
    - specify overrides
    - disable file lookup

## Install
```sh
npm install rcloader
```

## Use
This plugin was written to specifically address this issue for a couple of gulp plugins.

### within a gulp plugin
```js
var RcLoader = require('rcloader');
var map = require('map-stream');

module.exports = function MyGulpPlugin(options) {
  var rcLoader = new RcLoader('.configfilename', options);

  return map(function (file, cb) {
    // get the options for this file specifically
    rcLoader.for(file.path, function (err, fileOpts) {
      // do something cool

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

If you would rather, just skip the callback and it will run synchronously.
```js
var fileOpts = rcLoader.for(file.path, options);
```

## Options
The second argument to the `RcLoader` constructor should be the options that plugin consumers define, and it can take a few different forms.

**If the user specifies a string**, it is used as a path to the only config file that they care about. Calling `rcLoader.for(path)` will always return a copy of the config file at that path.

**If the user specifies an object**, the following keys will be stripped from it:

- `lookup`, Boolean: Find the closest config file each time `.for()` is called. default is true, unless `options` is a path.
- `defaultFile`, string: Specify a default configuration file.

If `defaultFile` is not specified, all values except `lookup` will override values found in the config file.

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