diff options
author | Ruy Adorno <ruyadorno@hotmail.com> | 2021-03-12 00:10:12 +0300 |
---|---|---|
committer | Ruy Adorno <ruyadorno@hotmail.com> | 2021-03-12 00:10:12 +0300 |
commit | 57ed390d64a44ae0a1b2c4afd79d690170b194ec (patch) | |
tree | 8eea84950274856c99cc0e3833ac0172d6d816ec /node_modules/@npmcli | |
parent | 8c44e999bdf7639893535c55beebf7996da2c47f (diff) |
@npmcli/arborist@2.2.8
Diffstat (limited to 'node_modules/@npmcli')
-rw-r--r-- | node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js | 16 | ||||
-rw-r--r-- | node_modules/@npmcli/arborist/lib/printable.js | 17 | ||||
-rw-r--r-- | node_modules/@npmcli/arborist/lib/shrinkwrap.js | 18 | ||||
-rw-r--r-- | node_modules/@npmcli/arborist/package.json | 2 |
4 files changed, 44 insertions, 9 deletions
diff --git a/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js b/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js index 412d6ce8b..f7e5b7e32 100644 --- a/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js +++ b/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js @@ -883,6 +883,8 @@ This is a one-time fix-up, please be patient... // create a virtual root node with the same deps as the node that // is requesting this one, so that we can get all the peer deps in // a context where they're likely to be resolvable. + // Note that the virtual root will also have virtual copies of the + // targets of any child Links, so that they resolve appropriately. const parent = parent_ || this[_virtualRoot](edge.from) const realParent = edge.peer ? edge.from.resolveParent : edge.from @@ -936,11 +938,23 @@ This is a one-time fix-up, please be patient... return this[_virtualRoots].get(node) const vr = new Node({ - path: '/virtual-root', + path: node.realpath, sourceReference: node, legacyPeerDeps: this.legacyPeerDeps, }) + // also need to set up any targets from any link deps, so that + // they are properly reflected in the virtual environment + for (const child of node.children.values()) { + if (child.isLink) { + new Node({ + path: child.realpath, + sourceReference: child.target, + root: vr, + }) + } + } + this[_virtualRoots].set(node, vr) return vr } diff --git a/node_modules/@npmcli/arborist/lib/printable.js b/node_modules/@npmcli/arborist/lib/printable.js index fb73c7c2b..588121dbc 100644 --- a/node_modules/@npmcli/arborist/lib/printable.js +++ b/node_modules/@npmcli/arborist/lib/printable.js @@ -63,6 +63,13 @@ class ArboristNode { } } +class ArboristVirtualNode extends ArboristNode { + constructor (tree, path) { + super(tree, path) + this.sourceReference = printableTree(tree.sourceReference, path) + } +} + class ArboristLink extends ArboristNode { constructor (tree, path) { super(tree, path) @@ -119,10 +126,14 @@ class EdgeIn extends Edge { } const printableTree = (tree, path = []) => { - if (path.includes(tree)) - return { location: tree.location } + const Cls = tree.isLink ? ArboristLink + : tree.sourceReference ? ArboristVirtualNode + : ArboristNode + if (path.includes(tree)) { + const obj = Object.create(Cls.prototype) + return Object.assign(obj, { location: tree.location }) + } path.push(tree) - const Cls = tree.isLink ? ArboristLink : ArboristNode return new Cls(tree, path) } diff --git a/node_modules/@npmcli/arborist/lib/shrinkwrap.js b/node_modules/@npmcli/arborist/lib/shrinkwrap.js index 828b9f328..342e78e9e 100644 --- a/node_modules/@npmcli/arborist/lib/shrinkwrap.js +++ b/node_modules/@npmcli/arborist/lib/shrinkwrap.js @@ -41,6 +41,7 @@ const readFile = promisify(fs.readFile) const writeFile = promisify(fs.writeFile) const stat = promisify(fs.stat) const readdir_ = promisify(fs.readdir) +const readlink = promisify(fs.readlink) // XXX remove when drop support for node v10 const lstat = promisify(fs.lstat) @@ -176,10 +177,19 @@ const assertNoNewer = async (path, data, lockTime, dir = path, seen = null) => { : readdir(parent, { withFileTypes: true }) return children.catch(() => []) - .then(ents => Promise.all( - ents.filter(ent => ent.isDirectory() && !/^\./.test(ent.name)) - .map(ent => assertNoNewer(path, data, lockTime, resolve(parent, ent.name), seen)) - )).then(() => { + .then(ents => Promise.all(ents.map(async ent => { + const child = resolve(parent, ent.name) + if (ent.isDirectory() && !/^\./.test(ent.name)) + await assertNoNewer(path, data, lockTime, child, seen) + else if (ent.isSymbolicLink()) { + const target = resolve(parent, await readlink(child)) + const tstat = await stat(target).catch(() => null) + seen.add(relpath(path, child)) + if (tstat && tstat.isDirectory() && !seen.has(relpath(path, target))) + await assertNoNewer(path, data, lockTime, target, seen) + } + }))) + .then(() => { if (dir !== path) return diff --git a/node_modules/@npmcli/arborist/package.json b/node_modules/@npmcli/arborist/package.json index 35623f90c..bff10db4b 100644 --- a/node_modules/@npmcli/arborist/package.json +++ b/node_modules/@npmcli/arborist/package.json @@ -1,6 +1,6 @@ { "name": "@npmcli/arborist", - "version": "2.2.7", + "version": "2.2.8", "description": "Manage node_modules trees", "dependencies": { "@npmcli/installed-package-contents": "^1.0.7", |