dependencies-hierarchy
Creates a dependencies hierarchy for a symlinked `node_modules`
A symlinked node_modules
is created when installing using pnpm.
Install
Install it via npm.
npm install dependencies-hierarchy
Usage
'use strict'
const hierarchyForPackages = require('dependencies-hierarchy').forPackages
hierarchyForPackages(['graceful-fs', {name: 'pify', range: '2'}], __dirname, {depth: 2})
.then(tree => {
console.log(JSON.stringify(tree, null, 2))
})
API
default: dependenciesHierarchy(projectPath, [opts]): Promise<Hierarchy>
Creates a dependency tree for a project's node_modules
.
Arguments:
projectPath
- String - The path to the project.[opts.depth]
- Number - 0 by default. How deep should the node_modules
be analyzed.[opts.only]
- 'dev' | 'prod' - Optional. If set to dev
, then only packages from devDependencies
are analyzed.
If set to prod
, then only packages from dependencies
are analyzed.
forPackages(packageSelectors, projectPath, [opts]): Promise<Hierarchy>
Creates a dependency tree for a project's node_modules
. Limits the results to only the paths to the packages named.
Arguments:
packageSelectors
- (string | {name: string, version: string})[] - An array that consist of package names or package names and version ranges.
E.g. ['foo', {name: 'bar', version: '^2.0.0'}]
.projectPath
- String - The path to the project[opts.depth]
- Number - 0 by default. How deep should the node_modules
be analyzed.[opts.only]
- 'dev' | 'prod' - Optional. If set to dev
, then only packages from devDependencies
are analyzed.
If set to prod
, then only packages from dependencies
are analyzed.
License
MIT © Zoltan Kochan