Skip to content
This repository was archived by the owner on Feb 3, 2025. It is now read-only.

nodesource/universal-module-tree

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

universal-module-tree

Build Status

Get a full module tree from package-lock.json, yarn.lock or node_modules/**.

Usage

const getTree = require('universal-module-tree')

const tree = await getTree(__dirname)
console.log(JSON.stringify(tree, null, 2))
$ node example.js | head -n25
{
  "children": [
    {
      "data": {
        "name": "@yarnpkg/lockfile",
        "version": "1.1.0"
      },
      "children": []
    },
    {
      "data": {
        "name": "read-package-tree",
        "version": "5.2.1"
      },
      "children": [
        {
          "data": {
            "name": "debuglog",
            "version": "1.0.1"
          },
          "children": []
        },
        {
          "data": {
            "name": "dezalgo",

Or with NSolid:

const getTree = require('universal-module-tree')

nsolid.packages((err, packages) => {
  if (err) throw err
  const tree = getTree.fromNSolid(packages)
  console.log(JSON.stringify(tree, null, 2))
})

Installation

$ npm install universal-module-tree

API

getTree(dir, { noDev = false }) => Promise

getTree.fromPackageLock({ packageLock, packageJSON, noDev = false }) => Object

getTree.fromYarnLock({ yarnLock, packageJSON, noDev = false }) => Object

getTree.fromNodeModules(path, { noDev = false }) => Promise

getTree.fromNSolid(packages) => Object

getTree.flatten(tree) => Array

Options

  • noDev: exclude devDependencies

License & copyright

Copyright © NodeSource.

Licensed under the MIT open source license, see the LICENSE file for details.

About

Get a module tree from package-lock.json / yarn.lock / node_modules

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •