README.md 1.79 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
# @istanbuljs/load-nyc-config

The utility function which NYC uses to load configuration.
This can be used by outside programs to calculate the configuration.
Command-line arguments are not considered by this function.

```js
const {loadNycConfig} = require('@istanbuljs/load-nyc-config');

console.log(loadNycConfig());
```

## loadNycConfig([options])

### options.cwd

Type: `string`
Default: `cwd` from parent nyc process or `process.cwd()`

### options.nycrcPath

Type: `string`
Default: `undefined`

Name of the file containing nyc configuration.
This can be a relative or absolute path.
Relative paths can exist at `options.cwd` or any parent directory.
If an nycrc is specified but cannot be found an exception is thrown.

If no nycrc option is provided the default priority of config files are:

* .nycrc
* .nycrc.json
* .nycrc.yml
* .nycrc.yaml
* nyc.config.js

## Configuration merging

Configuration is first loaded from `package.json` if found, this serves as the package
defaults.  These options can be overridden by an nycrc if found.  Arrays are not merged,
so if `package.json` sets `"require": ["@babel/register"]` and `.nycrc` sets `"require": ["esm"]`
the effective require setting will only include `"esm"`.

## `@istanbuljs/load-nyc-config` for enterprise

Available as part of the Tidelift Subscription.

The maintainers of `@istanbuljs/load-nyc-config` and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Learn more.](https://tidelift.com/subscription/pkg/npm-istanbuljs-load-nyc-config?utm_source=npm-istanbuljs-load-nyc-config&utm_medium=referral&utm_campaign=enterprise)