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

fix: honor explicit prefix #254

Merged
merged 2 commits into from
Mar 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/arborist/reify.js
Original file line number Diff line number Diff line change
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
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"promise-call-limit": "^1.0.1",
"read-package-json-fast": "^2.0.2",
"readdir-scoped-modules": "^1.1.0",
"semver": "^7.3.4",
"semver": "^7.3.5",
"tar": "^6.1.0",
"treeverse": "^1.0.4",
"walk-up-path": "^1.0.0"
Expand Down
11 changes: 11 additions & 0 deletions tap-snapshots/test-arborist-reify.js-TAP.test.js
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, this looks weird. Probably shouldn't end up with the name in there...

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