npm

Does your artifact manager get in the way? Join us on Oct. 8 at 10am PT, to discuss how npm can help.Sign up »

pkg-discovery

2.0.0 • Public • Published

pkg-discovery

Version Downloads Build Status Codecov License

Discovery the dependencies and devDependencies of package

Install

npm install --save pkg-discovery

Usage

const pkgDiscovery = require('pkg-discovery');
 
(async () => {
  console.log(await pkgDiscovery({ field: 'foo' }));
  /*
  Dependencies that have the `foo` field  on your `package.json`
  {
    'dependency-1': {
      content of `foo` field
    },
 
    'dependency-2': {
      content of `foo` field
    }
  }
  */
})();

API

pkgDiscovery(options?)

Returns a Promise<object> or Promise<{}> if no package.json was found.

pkgDiscovery.sync(options?)

Returns the result object or object empty if no package.json was found.

options

  • Type: object
field
  • Type: string
  • Default: undefined

If field option is set, all packages should contain this field.

dir
  • Type: string
  • Default: process.cwd()

Directory to start looking for a package.json file.

dev
  • Type: boolean
  • Defualt: false

When the dev parameter is enabled the discovery will be done in devDependencies, otherwise in dependencies.

exclude
  • Type: array
  • Default: []

The exclude parameter is an array to exclude packages to be discovered.

filter
  • Type: function
  • Default: undefined

If filter option is set as a function, all packages will be filtered through it.

install

npm i pkg-discovery

Downloadsweekly downloads

0

version

2.0.0

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability