Skip to content
This repository has been archived by the owner on Jan 20, 2022. It is now read-only.

Commit

Permalink
fix global update all so it actually updates things
Browse files Browse the repository at this point in the history
PR-URL: #215
Credit: @nlf
Close: #215
Reviewed-by: @isaacs
  • Loading branch information
nlf authored and isaacs committed Jan 29, 2021
1 parent 3bf786c commit d94f068
Show file tree
Hide file tree
Showing 3 changed files with 171 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/arborist/build-ideal-tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
}
Expand Down
2 changes: 1 addition & 1 deletion lib/arborist/reify.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
169 changes: 169 additions & 0 deletions tap-snapshots/test-arborist-build-ideal-tree.js-TAP.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down

0 comments on commit d94f068

Please sign in to comment.