JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1622751
  • Score
    100M100P100Q13904F
  • License MIT

Get namespaced config from the closest package.json

Package Exports

  • pkg-conf

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (pkg-conf) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

pkg-conf Build Status

Get namespaced config from the closest package.json

For example, XO uses the xo namespace in package.json and ESLint uses eslintConfig.

Install

$ npm install --save pkg-conf

Usage

{
    "name": "some-package",
    "version": "1.0.0",
    "unicorn": {
        "rainbow": true
    }
}
var pkgConf = require('pkg-conf');

pkgConf('unicorn').then(function (config) {
    console.log(config.rainbow);
    //=> true
});

API

It walks up parent directories until a package.json can be found, reads it, and returns the user specified namespace or an empty object if not found.

pkgConf(namespace, [cwd])

Returns a promise that resolves to the config.

pkgConf.sync(namespace, [cwd])

Returns the config.

namespace

Type: string

The package.json namespace you want.

cwd

Type: string
Default: .

Directory to start looking for a package.json file.

pkgConf.filepath(config)

Pass in the config returned from any of the above methods.

Returns the filepath to the package.json file or null.

  • read-pkg - Read a package.json file
  • find-up - Find a file by walking up parent directories

License

MIT © Sindre Sorhus