# rcload

> Find and load json configuration from a package.json property, rc file, or CommonJS module

Latest version **1.0.0** (published 2020-01-14) · MIT license · 0 weekly downloads

## Install

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

## 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 | 1.0.0 |
| Published | 2020-01-14 |
| First published | 2020-01-14 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Jeppe Hasseriis |
| Maintainers | jhass |
| Keywords | rc, config, json, node, nodejs |

## Links

- npm: https://www.npmjs.com/package/rcload
- Repository: https://github.com/cenobitedk/rcconfig
- Homepage: https://github.com/cenobitedk/rcconfig#readme
- Issues: https://github.com/cenobitedk/rcconfig/issues
- npm.io page: https://npm.io/package/rcload

## 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

- 1.0.0 (latest) — 2020-01-14

## README

# rcload

Find and load json configuration from a package.json property, rc file, or CommonJS module.

Heavily inspired by [cosmiconfig](https://www.npmjs.com/package/cosmiconfig), but super simplified for minimal bundlesize.  
The big difference from cosmiconfig is that **rcload does not support yaml files**.

**rcload** will search for the following:

- a `package.json` property
- a JSON extensionless "rc file"
- an "rc file" with the extensions `.json` or `.js`
- a `.config.js` CommonJS module

It is also meant as a partial drop-in replacement which means it return a `result` object same as cosmiconfig.

## Differences from [cosmiconfig](https://www.npmjs.com/package/cosmiconfig)

- Supports only JSON and CommonJS formats.
- Only looks in `process.cwd()`.
- Limited options.
- Only synchronous load.

## Usage

Install as a dependency.

```
npm i rcload
```

Use in your application.

```
const rcload = require('rcload');

const result = rcload('myapp');
```

## Result

The result object has the following properties:

- `config`: The parsed configuration object. `undefined` if the file is empty.
- `filepath`: The path to the configuration file that was found.
- `isEmpty`: true if the configuration file is empty.

In contrast to cosmiconfig, `isEmpty` will remain in the result object when the config is found, e.g.:

```
const result = rcload('myapp');
// {
//     config: {
//         ...
//     },
//     filepath: "/users/johndoe/www/myapp/.myapprc",
//     isEmpty: false
// }
```

## Options

**rcload** takes an options object:

- `cwd`: the full directory path to search in. Common for `package.json` and rc files. Defaults to `process.cwd()`.

If you want your config files in another directory this will help, e.g.:

```
rcload('myapp', {
    cwd: path.join(process.cwd(), 'configs')
})
```

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