Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(arborist): check placed node children for missing deps (#7746) #7752

Open
wants to merge 1 commit into
base: latest
Choose a base branch
from
Open
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
4 changes: 4 additions & 0 deletions workspaces/arborist/lib/arborist/build-ideal-tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -988,8 +988,12 @@ This is a one-time fix-up, please be patient...
}

// lastly, also check for the missing deps of the node we placed,
// as well as any missing deps of the new node's children,
// and any holes created by pruning out conflicted peer sets.
this.#depsQueue.push(placed)
for (const child of placed.children.values()) {
this.#depsQueue.push(child)
}
for (const dep of pd.needEvaluation) {
this.#depsSeen.delete(dep)
this.#depsQueue.push(dep)
Expand Down
9 changes: 9 additions & 0 deletions workspaces/arborist/test/arborist/reify.js
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,15 @@ t.test('update a node without updating a child that has bundle deps', t => {
}))
})

t.test('restore missing parent while preserving child node', async t => {
const path = fixture(t, 'lockfile-with-missing-parent')
await reify(path)
const parentPath = `${path}/node_modules/globby`
t.equal(fs.statSync(`${parentPath}/package.json`).isFile(), true, 'parent has package.json')
const childPath = `${path}/node_modules/globby/node_modules/minimatch`
t.equal(fs.statSync(`${childPath}/package.json`).isFile(), true, 'child has package.json')
})

t.test('optional dependency failures', t => {
const cases = [
'optional-dep-tgz-missing',
Expand Down

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

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"name": "lockfile-with-missing-parent",
"version": "1.0.0",
"dependencies": {
"glob": "7.1.6",
"globby": "1.2.0",
"minimatch": "3.0.3"
}
}
Loading
Loading