gather-package-details
Given the directory of a project utilizing npm and a list of file paths, collect package information pertaining to each path.
install
npm install gather-package-details
usage
This module exports a single function, gatherPackageDetails()
, which takes an options object. The following options can/must be specified:
projectRoot
- required, path to the root of the project which is being investigatedmodulePaths
- required, an array of paths to files that should be traced back to packageslicenseOverrides
- an optional map of license names for specific packages. The keys of this object should be formatted asname@version
, and the values can be any value
The method returns a promise for the details, { project, unresolved }
details.project
- the root package, or project package, which is the parent to all of the discovered packages. SeePackage
for details about it's propertiesdetails.unresolved
- an array of themodulePaths
that could not be matched to a package
examples
See the examples directory for usage:
Package
The Package
class represents a node package, identified by a directory containing a package.json file. Each package has the following properties:
name
- the name of the packageversion
- the version, read from the package.json filedirectory
- the directory where the package was foundlicenses
- An array of license identifiers which this package advertises, or the values passed in via thelicenseOverrides
option.children
- An array of sub-Package
s that were found
other modules
This module is simply a wrapper around license-checker and read-package-tree, if you are looking for more low-level tools I suggest using those.