Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

dependencies-hierarchy

Package Overview
Dependencies
Maintainers
1
Versions
167
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dependencies-hierarchy

Creates a dependencies hierarchy for a symlinked `node_modules`

  • 2.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
38
decreased by-33.33%
Maintainers
1
Weekly downloads
 
Created
Source

dependencies-hierarchy

Creates a dependencies hierarchy for a symlinked `node_modules`

npm version Build Status

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))
    //> [
    //    {
    //      "dependencies": [
    //        {
    //          "dependencies": [
    //            {
    //              "pkg": {
    //                "name": "graceful-fs",
    //                "path": "registry.npmjs.org/graceful-fs/4.1.11",
    //                "version": "4.1.11"
    //              },
    //              "searched": true
    //            },
    //            {
    //              "pkg": {
    //                "name": "pify",
    //                "path": "registry.npmjs.org/pify/2.3.0",
    //                "version": "2.3.0"
    //              },
    //              "searched": true
    //            }
    //          ],
    //          "pkg": {
    //            "name": "write-json-file",
    //            "path": "registry.npmjs.org/write-json-file/2.2.0",
    //            "version": "2.2.0"
    //          }
    //        }
    //      ],
    //      "pkg": {
    //        "name": "write-pkg",
    //        "path": "registry.npmjs.org/write-pkg/3.1.0",
    //        "version": "3.1.0"
    //      }
    //    }
    //  ]
  })

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

Keywords

FAQs

Package last updated on 11 Jan 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc