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

Commit 5a4b58c

Browse files
James Chen-Smithisaacs
authored andcommitted
fix: honor explicit prefix
Honors explicit prefix. Signed-off-by: James Chen-Smith <jameschensmith@gmail.com> PR-URL: #254 Credit: @jameschensmith Close: #254 Reviewed-by: @isaacs
1 parent 9792bb4 commit 5a4b58c

3 files changed

Lines changed: 27 additions & 5 deletions

File tree

lib/arborist/reify.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -890,7 +890,7 @@ module.exports = cls => class Reifier extends cls {
890890
const root = this.idealTree
891891
const pkg = root.package
892892
for (const { name } of this[_resolvedAdd]) {
893-
const req = npa(root.edgesOut.get(name).spec, root.realpath)
893+
const req = npa.resolve(name, root.edgesOut.get(name).spec, root.realpath)
894894
const {rawSpec, subSpec} = req
895895

896896
const spec = subSpec ? subSpec.rawSpec : rawSpec

tap-snapshots/test-arborist-reify.js-TAP.test.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29029,6 +29029,11 @@ Object {
2902929029
"extraneous": true,
2903029030
"resolved": "https://registry.npmjs.org/g/-/g-1.2.3.tgz",
2903129031
},
29032+
"h": Object {
29033+
"extraneous": true,
29034+
"resolved": "https://registry.npmjs.org/h/-/h-1.2.3.tgz",
29035+
"version": "1.2.3",
29036+
},
2903229037
},
2903329038
"lockfileVersion": 2,
2903429039
"name": "reify-saving-the-ideal-tree-save-some-stuff",
@@ -29046,6 +29051,7 @@ Object {
2904629051
"e": "file:e",
2904729052
"f": "git+https://user:pass@github.com/baz/quux.git#asdf",
2904829053
"g": "*",
29054+
"h": "~1.2.3",
2904929055
},
2905029056
"devDependencies": Object {
2905129057
"c": "git+ssh://git@githost.com:a/b/c.git#master",
@@ -29092,6 +29098,11 @@ Object {
2909229098
"extraneous": true,
2909329099
"resolved": "https://registry.npmjs.org/g/-/g-1.2.3.tgz",
2909429100
},
29101+
"node_modules/h": Object {
29102+
"extraneous": true,
29103+
"resolved": "https://registry.npmjs.org/h/-/h-1.2.3.tgz",
29104+
"version": "1.2.3",
29105+
},
2909529106
},
2909629107
"requires": true,
2909729108
}

test/arborist/reify.js

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -808,11 +808,12 @@ t.test('saving the ideal tree', t => {
808808
dependencies: {
809809
a: 'git+ssh://git@github.com:foo/bar#baz',
810810
b: '',
811-
d: 'd@npm:c@1.x <1.9.9',
811+
d: 'npm:c@1.x <1.9.9',
812812
// XXX: should we remove dependencies that are also workspaces?
813813
e: 'file:e',
814814
f: 'git+https://user:pass@github.com/baz/quux#asdf',
815815
g: '',
816+
h: '~1.2.3',
816817
},
817818
devDependencies: {
818819
c: `git+ssh://git@githost.com:a/b/c.git#master`,
@@ -891,6 +892,16 @@ t.test('saving the ideal tree', t => {
891892
},
892893
parent: tree,
893894
})
895+
new Node({
896+
name: 'h',
897+
resolved: 'https://registry.npmjs.org/h/-/h-1.2.3.tgz',
898+
pkg: {
899+
name: 'h',
900+
version: '1.2.3',
901+
},
902+
parent: tree,
903+
})
904+
894905
const target = new Node({
895906
name: 'e',
896907
pkg: {
@@ -917,12 +928,11 @@ t.test('saving the ideal tree', t => {
917928
npa('e'),
918929
npa('f@git+https://user:pass@github.com/baz/quux#asdf'),
919930
npa('g'),
931+
npa('h@~1.2.3'),
920932
]
921933
// NB: these are all going to be marked as extraneous, because we're
922934
// skipping the actual buildIdealTree step that flags them properly
923-
return a[kSaveIdealTree]({
924-
savePrefix: '~',
925-
})
935+
return a[kSaveIdealTree]({})
926936
}).then(() => {
927937
t.matchSnapshot(require(path + '/package-lock.json'), 'lock after save')
928938
t.strictSame(require(path + '/package.json'), {
@@ -934,6 +944,7 @@ t.test('saving the ideal tree', t => {
934944
e: 'file:e',
935945
f: 'git+https://user:pass@github.com/baz/quux.git#asdf',
936946
g: '*',
947+
h: '~1.2.3',
937948
},
938949
workspaces: [
939950
'e',

0 commit comments

Comments
 (0)