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

Commit

Permalink
fix: honor explicit prefix
Browse files Browse the repository at this point in the history
Honors explicit prefix.

Signed-off-by: James Chen-Smith <jameschensmith@gmail.com>

PR-URL: #254
Credit: @jameschensmith
Close: #254
Reviewed-by: @isaacs
  • Loading branch information
James Chen-Smith authored and isaacs committed Mar 23, 2021
1 parent 9792bb4 commit 5a4b58c
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/arborist/reify.js
Expand Up @@ -890,7 +890,7 @@ module.exports = cls => class Reifier extends cls {
const root = this.idealTree
const pkg = root.package
for (const { name } of this[_resolvedAdd]) {
const req = npa(root.edgesOut.get(name).spec, root.realpath)
const req = npa.resolve(name, root.edgesOut.get(name).spec, root.realpath)
const {rawSpec, subSpec} = req

const spec = subSpec ? subSpec.rawSpec : rawSpec
Expand Down
11 changes: 11 additions & 0 deletions tap-snapshots/test-arborist-reify.js-TAP.test.js
Expand Up @@ -29029,6 +29029,11 @@ Object {
"extraneous": true,
"resolved": "https://registry.npmjs.org/g/-/g-1.2.3.tgz",
},
"h": Object {
"extraneous": true,
"resolved": "https://registry.npmjs.org/h/-/h-1.2.3.tgz",
"version": "1.2.3",
},
},
"lockfileVersion": 2,
"name": "reify-saving-the-ideal-tree-save-some-stuff",
Expand All @@ -29046,6 +29051,7 @@ Object {
"e": "file:e",
"f": "git+https://user:pass@github.com/baz/quux.git#asdf",
"g": "*",
"h": "~1.2.3",
},
"devDependencies": Object {
"c": "git+ssh://git@githost.com:a/b/c.git#master",
Expand Down Expand Up @@ -29092,6 +29098,11 @@ Object {
"extraneous": true,
"resolved": "https://registry.npmjs.org/g/-/g-1.2.3.tgz",
},
"node_modules/h": Object {
"extraneous": true,
"resolved": "https://registry.npmjs.org/h/-/h-1.2.3.tgz",
"version": "1.2.3",
},
},
"requires": true,
}
Expand Down
19 changes: 15 additions & 4 deletions test/arborist/reify.js
Expand Up @@ -808,11 +808,12 @@ t.test('saving the ideal tree', t => {
dependencies: {
a: 'git+ssh://git@github.com:foo/bar#baz',
b: '',
d: 'd@npm:c@1.x <1.9.9',
d: 'npm:c@1.x <1.9.9',
// XXX: should we remove dependencies that are also workspaces?
e: 'file:e',
f: 'git+https://user:pass@github.com/baz/quux#asdf',
g: '',
h: '~1.2.3',
},
devDependencies: {
c: `git+ssh://git@githost.com:a/b/c.git#master`,
Expand Down Expand Up @@ -891,6 +892,16 @@ t.test('saving the ideal tree', t => {
},
parent: tree,
})
new Node({
name: 'h',
resolved: 'https://registry.npmjs.org/h/-/h-1.2.3.tgz',
pkg: {
name: 'h',
version: '1.2.3',
},
parent: tree,
})

const target = new Node({
name: 'e',
pkg: {
Expand All @@ -917,12 +928,11 @@ t.test('saving the ideal tree', t => {
npa('e'),
npa('f@git+https://user:pass@github.com/baz/quux#asdf'),
npa('g'),
npa('h@~1.2.3'),
]
// NB: these are all going to be marked as extraneous, because we're
// skipping the actual buildIdealTree step that flags them properly
return a[kSaveIdealTree]({
savePrefix: '~',
})
return a[kSaveIdealTree]({})
}).then(() => {
t.matchSnapshot(require(path + '/package-lock.json'), 'lock after save')
t.strictSame(require(path + '/package.json'), {
Expand All @@ -934,6 +944,7 @@ t.test('saving the ideal tree', t => {
e: 'file:e',
f: 'git+https://user:pass@github.com/baz/quux.git#asdf',
g: '*',
h: '~1.2.3',
},
workspaces: [
'e',
Expand Down

0 comments on commit 5a4b58c

Please sign in to comment.