diff --git a/lib/arborist/build-ideal-tree.js b/lib/arborist/build-ideal-tree.js index 9328b8043..7b4fdd593 100644 --- a/lib/arborist/build-ideal-tree.js +++ b/lib/arborist/build-ideal-tree.js @@ -416,7 +416,7 @@ module.exports = cls => class IdealTreeBuilder extends cls { await this[_add](options) // triggers a refresh of all edgesOut - if (options.add && options.add.length || options.rm && options.rm.length) + if (options.add && options.add.length || options.rm && options.rm.length || this[_global]) tree.package = tree.package process.emit('timeEnd', 'idealTree:userRequests') } diff --git a/lib/arborist/reify.js b/lib/arborist/reify.js index 19c7fa384..34c1dbb18 100644 --- a/lib/arborist/reify.js +++ b/lib/arborist/reify.js @@ -233,7 +233,7 @@ module.exports = cls => class Reifier extends cls { const actualOpt = this[_global] ? { ignoreMissing: true, global: true, - filter: (node, kid) => !node.isRoot && node !== node.root.target + filter: (node, kid) => this[_explicitRequests].size === 0 || !node.isProjectRoot ? true : (node.edgesOut.has(kid) || this[_explicitRequests].has(kid)), } : { ignoreMissing: true } diff --git a/tap-snapshots/test-arborist-build-ideal-tree.js-TAP.test.js b/tap-snapshots/test-arborist-build-ideal-tree.js-TAP.test.js index d419032bc..b83ccc8dc 100644 --- a/tap-snapshots/test-arborist-build-ideal-tree.js-TAP.test.js +++ b/tap-snapshots/test-arborist-build-ideal-tree.js-TAP.test.js @@ -128524,6 +128524,56 @@ ArboristNode { exports[`test/arborist/build-ideal-tree.js TAP update global > update a single dep 1`] = ` ArboristNode { + "children": Map { + "once" => ArboristNode { + "children": Map { + "wrappy" => ArboristNode { + "edgesIn": Set { + EdgeIn { + "from": "node_modules/once", + "name": "wrappy", + "spec": "1", + "type": "prod", + }, + }, + "location": "node_modules/once/node_modules/wrappy", + "name": "wrappy", + "path": "{CWD}/test/arborist/build-ideal-tree-update-global/node_modules/once/node_modules/wrappy", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "version": "1.0.2", + }, + }, + "edgesIn": Set { + EdgeIn { + "from": "", + "name": "once", + "spec": "*", + "type": "prod", + }, + }, + "edgesOut": Map { + "wrappy" => EdgeOut { + "name": "wrappy", + "spec": "1", + "to": "node_modules/once/node_modules/wrappy", + "type": "prod", + }, + }, + "location": "node_modules/once", + "name": "once", + "path": "{CWD}/test/arborist/build-ideal-tree-update-global/node_modules/once", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "version": "1.4.0", + }, + }, + "edgesOut": Map { + "once" => EdgeOut { + "name": "once", + "spec": "*", + "to": "node_modules/once", + "type": "prod", + }, + }, "location": "", "name": "build-ideal-tree-update-global", "path": "{CWD}/test/arborist/build-ideal-tree-update-global", @@ -128532,6 +128582,125 @@ ArboristNode { exports[`test/arborist/build-ideal-tree.js TAP update global > update all the deps 1`] = ` ArboristNode { + "children": Map { + "@isaacs/testing-dev-optional-flags" => ArboristNode { + "children": Map { + "own-or" => ArboristNode { + "edgesIn": Set { + EdgeIn { + "from": "node_modules/@isaacs/testing-dev-optional-flags", + "name": "own-or", + "spec": "^1.0.0", + "type": "optional", + }, + }, + "location": "node_modules/@isaacs/testing-dev-optional-flags/node_modules/own-or", + "name": "own-or", + "optional": true, + "path": "{CWD}/test/arborist/build-ideal-tree-update-global/node_modules/@isaacs/testing-dev-optional-flags/node_modules/own-or", + "resolved": "https://registry.npmjs.org/own-or/-/own-or-1.0.0.tgz", + "version": "1.0.0", + }, + "wrappy" => ArboristNode { + "edgesIn": Set { + EdgeIn { + "from": "node_modules/@isaacs/testing-dev-optional-flags", + "name": "wrappy", + "spec": "^1.0.2", + "type": "optional", + }, + }, + "location": "node_modules/@isaacs/testing-dev-optional-flags/node_modules/wrappy", + "name": "wrappy", + "optional": true, + "path": "{CWD}/test/arborist/build-ideal-tree-update-global/node_modules/@isaacs/testing-dev-optional-flags/node_modules/wrappy", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "version": "1.0.2", + }, + }, + "edgesIn": Set { + EdgeIn { + "from": "", + "name": "@isaacs/testing-dev-optional-flags", + "spec": "*", + "type": "prod", + }, + }, + "edgesOut": Map { + "own-or" => EdgeOut { + "name": "own-or", + "spec": "^1.0.0", + "to": "node_modules/@isaacs/testing-dev-optional-flags/node_modules/own-or", + "type": "optional", + }, + "wrappy" => EdgeOut { + "name": "wrappy", + "spec": "^1.0.2", + "to": "node_modules/@isaacs/testing-dev-optional-flags/node_modules/wrappy", + "type": "optional", + }, + }, + "location": "node_modules/@isaacs/testing-dev-optional-flags", + "name": "@isaacs/testing-dev-optional-flags", + "path": "{CWD}/test/arborist/build-ideal-tree-update-global/node_modules/@isaacs/testing-dev-optional-flags", + "resolved": "https://registry.npmjs.org/@isaacs/testing-dev-optional-flags/-/testing-dev-optional-flags-1.0.0.tgz", + "version": "1.0.0", + }, + "once" => ArboristNode { + "children": Map { + "wrappy" => ArboristNode { + "edgesIn": Set { + EdgeIn { + "from": "node_modules/once", + "name": "wrappy", + "spec": "1", + "type": "prod", + }, + }, + "location": "node_modules/once/node_modules/wrappy", + "name": "wrappy", + "path": "{CWD}/test/arborist/build-ideal-tree-update-global/node_modules/once/node_modules/wrappy", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "version": "1.0.2", + }, + }, + "edgesIn": Set { + EdgeIn { + "from": "", + "name": "once", + "spec": "*", + "type": "prod", + }, + }, + "edgesOut": Map { + "wrappy" => EdgeOut { + "name": "wrappy", + "spec": "1", + "to": "node_modules/once/node_modules/wrappy", + "type": "prod", + }, + }, + "location": "node_modules/once", + "name": "once", + "path": "{CWD}/test/arborist/build-ideal-tree-update-global/node_modules/once", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "version": "1.4.0", + }, + }, + "edgesOut": Map { + "@isaacs/testing-dev-optional-flags" => EdgeOut { + "name": "@isaacs/testing-dev-optional-flags", + "spec": "*", + "to": "node_modules/@isaacs/testing-dev-optional-flags", + "type": "prod", + }, + "once" => EdgeOut { + "name": "once", + "spec": "*", + "to": "node_modules/once", + "type": "prod", + }, + }, "location": "", "name": "build-ideal-tree-update-global", "path": "{CWD}/test/arborist/build-ideal-tree-update-global",