# pkg-config

> parse the closest `package.json` and get package specific configurations

Latest version **1.1.1** (published 2016-03-23) · MIT license · 0 weekly downloads

## Install

```sh
npm install pkg-config
pnpm add pkg-config
yarn add pkg-config
bun add pkg-config
```

## 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.1.1 |
| Published | 2016-03-23 |
| First published | 2015-05-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=0.10 |
| Dependencies | 3 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 9 |
| Author | Ahmad Nassri |
| Maintainers | ahmadnassri |
| Keywords | pkg-config |

## Links

- npm: https://www.npmjs.com/package/pkg-config
- Repository: https://github.com/ahmadnassri/pkg-config
- Issues: https://github.com/ahmadnassri/pkg-config/issues
- npm.io page: https://npm.io/package/pkg-config

## Dependencies (3)

- [xtend](https://npm.io/package/xtend.md) ^4.0.1
- [debug-log](https://npm.io/package/debug-log.md) ^1.0.0
- [find-root](https://npm.io/package/find-root.md) ^1.0.0

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

- 1.1.1 (latest) — 2016-03-23
- 1.1.0 — 2015-07-06
- 1.0.1 — 2015-06-12
- 1.0.0 — 2015-05-29
- 0.0.0 — 2015-05-29

## README

# pkg-config [![version][npm-version]][npm-url] [![License][npm-license]][license-url]

> parse the closest `package.json` and get package specific configurations

Useful for package developers to store package-related configuration in dependent's `package.json`.

defaults to `config` as root, which allows you to still leverage npm's standard [config](https://docs.npmjs.com/files/package.json#config)

[![Build Status][travis-image]][travis-url]
[![Downloads][npm-downloads]][npm-url]
[![Code Climate][codeclimate-quality]][codeclimate-url]
[![Coverage Status][codeclimate-coverage]][codeclimate-url]
[![Dependencies][david-image]][david-url]

## Install

```sh
npm install --save pkg-config
```

## Usage

###### sample package.json
```json
{
  ...

  "config": {
    "my-pkg": {
      "foo": "bar"
    }
  },

  "settings": {
    "some-pkg": {
      "foo": "bar"
    }
  }

  ...
}
```

```js
// defaults to `package.config`
var config = require('pkg-config')()

// returns `package.config[my-pkg]`
var config = require('pkg-config')('my-pkg')

// returns fallback value
var config = require('pkg-config')('another-pkg', false, {
  foo: 'baz'
})

// returns `package.settings[some-pkg]`
var config = require('pkg-config')('some-pkg', {
  root: 'settings'
})

// returns `package.settings`
var config = require('pkg-config')('settings', {
  root: false
})
```

## API

### config(namespace[, options, fallback])

#### Arguments

| name        | description                                                               | default     |
| ----------- | ------------------------------------------------------------------------- | ----------- |
| `namespace` | property name in `package.json`, typically this will be your package name | `undefined` |
| `option`    | see [`options`](#options)                                                               |
| `fallback`  | fallback value                                                            | `undefined` |

#### Options

| name    | description                                    | default       |
| ------  | ---------------------------------------------- | ------------- |
| `root`  | `package.json` object root                     | `config`      |
| `cwd`   | starting directory to look for `package.json`  | `process.cwd` |
| `cache` | cache `package.json`'s content                 | `true`        | 


## Support

Donations are welcome to help support the continuous development of this project.

[![Gratipay][gratipay-image]][gratipay-url]
[![PayPal][paypal-image]][paypal-url]
[![Flattr][flattr-image]][flattr-url]
[![Bitcoin][bitcoin-image]][bitcoin-url]

## License

[MIT](LICENSE) &copy; [Ahmad Nassri](https://www.ahmadnassri.com)

[license-url]: https://github.com/ahmadnassri/pkg-config/blob/master/LICENSE

[travis-url]: https://travis-ci.org/ahmadnassri/pkg-config
[travis-image]: https://img.shields.io/travis/ahmadnassri/pkg-config.svg?style=flat-square

[npm-url]: https://www.npmjs.com/package/pkg-config
[npm-license]: https://img.shields.io/npm/l/pkg-config.svg?style=flat-square
[npm-version]: https://img.shields.io/npm/v/pkg-config.svg?style=flat-square
[npm-downloads]: https://img.shields.io/npm/dm/pkg-config.svg?style=flat-square

[codeclimate-url]: https://codeclimate.com/github/ahmadnassri/pkg-config
[codeclimate-quality]: https://img.shields.io/codeclimate/github/ahmadnassri/pkg-config.svg?style=flat-square
[codeclimate-coverage]: https://img.shields.io/codeclimate/coverage/github/ahmadnassri/pkg-config.svg?style=flat-square

[david-url]: https://david-dm.org/ahmadnassri/pkg-config
[david-image]: https://img.shields.io/david/ahmadnassri/pkg-config.svg?style=flat-square

[gratipay-url]: https://www.gratipay.com/ahmadnassri/
[gratipay-image]: https://img.shields.io/gratipay/ahmadnassri.svg?style=flat-square

[paypal-url]: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=UJ2B2BTK9VLRS&on0=project&os0=pkg-config
[paypal-image]: http://img.shields.io/badge/paypal-donate-green.svg?style=flat-square

[flattr-url]: https://flattr.com/submit/auto?user_id=ahmadnassri&url=https://github.com/ahmadnassri/pkg-config&title=pkg-config&language=&tags=github&category=software
[flattr-image]: http://img.shields.io/badge/flattr-donate-green.svg?style=flat-square

[bitcoin-image]: http://img.shields.io/badge/bitcoin-1Nb46sZRVG3or7pNaDjthcGJpWhvoPpCxy-green.svg?style=flat-square
[bitcoin-url]: https://www.coinbase.com/checkouts/ae383ae6bb931a2fa5ad11cec115191e?name=pkg-config

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