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

fix: if there are children but the diff itself has an action, make sure to add it to leaves #233

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/diff.js
Expand Up @@ -105,7 +105,7 @@ const getChildren = diff => {
diffNode(actual, ideal, children, unchanged, removed)
}

if (diff.leaves && !children.length)
if (diff.leaves && !children.length || diff.action && diff.action !== 'REMOVE')
diff.leaves.push(diff)

return children
Expand Down
4 changes: 4 additions & 0 deletions tap-snapshots/test-diff.js-TAP.test.js
Expand Up @@ -19,13 +19,15 @@ Diff {
"integrity": "sha512-aaa",
},
"leaves": Array [
"/path/to/root/node_modules/b",
"/path/to/root/node_modules/b/node_modules/c",
"/path/to/root/node_modules/b/node_modules/d/node_modules/e",
"/path/to/root/node_modules/x/node_modules/y",
"/path/to/root/node_modules/p/node_modules/q",
"/path/to/root/node_modules/bundler/node_modules/not-bundled",
"/path/to/root/node_modules/should-have-bins",
"/path/to/root/foo/node_modules/baz",
"/path/to/root/node_modules/i",
"/path/to/root/node_modules/i/node_modules/j",
"/path/to/root/foo/node_modules/boo",
],
Expand Down Expand Up @@ -91,6 +93,7 @@ Diff {
"integrity": "sha512-BBB",
},
"leaves": Array [
"/path/to/root/node_modules/b",
"/path/to/root/node_modules/b/node_modules/c",
"/path/to/root/node_modules/b/node_modules/d/node_modules/e",
],
Expand Down Expand Up @@ -168,6 +171,7 @@ Diff {
"integrity": "sha512-III",
},
"leaves": Array [
"/path/to/root/node_modules/i",
"/path/to/root/node_modules/i/node_modules/j",
],
"unchanged": Array [],
Expand Down