@npmcli/arborist
Advanced tools
Comparing version 0.0.0-pre.5 to 0.0.0-pre.6
@@ -60,2 +60,15 @@ // a tree representing the difference between two trees | ||
const allChildren = node => { | ||
if (!node) | ||
return new Map() | ||
const kids = new Map() | ||
for (const n of [node, ...node.fsChildren]) { | ||
for (const kid of n.children.values()) { | ||
kids.set(kid.path, kid) | ||
} | ||
} | ||
return kids | ||
} | ||
// functions for the walk options when we traverse the trees | ||
@@ -67,16 +80,16 @@ // to create the diff tree | ||
// diff all the children | ||
const actualKids = diff.actual ? diff.actual.children : new Map() | ||
const idealKids = diff.ideal ? diff.ideal.children : new Map() | ||
const names = new Set([...actualKids.keys(), ...idealKids.keys()]) | ||
for (const name of names) { | ||
const actual = actualKids.get(name) | ||
const ideal = idealKids.get(name) | ||
// Note: we DON'T diff fsChildren themselves, because they are either | ||
// included in the package contents, or part of some other project, and | ||
// will never appear in legacy shrinkwraps anyway. but we _do_ include the | ||
// child nodes of fsChildren, because those are nodes that we are typically | ||
// responsible for installing. | ||
const actualKids = allChildren(diff.actual) | ||
const idealKids = allChildren(diff.ideal) | ||
const paths = new Set([...actualKids.keys(), ...idealKids.keys()]) | ||
for (const path of paths) { | ||
const actual = actualKids.get(path) | ||
const ideal = idealKids.get(path) | ||
diffNode(actual, ideal, children, unchanged, removed) | ||
} | ||
// Note: we DON'T diff fsChildren because they are either included | ||
// in the package contents, or part of some other project, and will | ||
// never appear in legacy shrinkwraps anyway. | ||
// XXX: provide a deep:true option to walk the *children* of fsChildren | ||
@@ -83,0 +96,0 @@ if (diff.leaves && !children.length) |
@@ -40,2 +40,3 @@ // a module that manages a shrinkwrap file (npm-shrinkwrap.json or | ||
const parseJSON = require('parse-conflict-json') | ||
const stringify = require('json-stringify-nice') | ||
@@ -656,3 +657,2 @@ const swKeyOrder = [ | ||
const json = stringify(this.commit(), swKeyOrder, this.indent) | ||
// XXX should we also hard-link to node_modules/arborist-lock.json? | ||
return Promise.all([ | ||
@@ -659,0 +659,0 @@ writeFile(this.filename, json), |
{ | ||
"name": "@npmcli/arborist", | ||
"version": "0.0.0-pre.5", | ||
"version": "0.0.0-pre.6", | ||
"description": "Manage node_modules trees", | ||
@@ -44,3 +44,3 @@ "dependencies": { | ||
"files": [ | ||
"lib/" | ||
"lib/**/*.js" | ||
], | ||
@@ -47,0 +47,0 @@ "main": "lib/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4438
188639
31