Skip to content
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
6 changes: 5 additions & 1 deletion lib/utils/validate-lockfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ function validateLockfile (virtualTree, idealTree) {
const lock = virtualTree.get(key)

if (!lock) {
errors.push(`Missing: ${entry.name}@${entry.version} from lock file`)
// Bundled dependencies are extracted from their parent's tarball and
// may not have independent lockfile entries.
if (!entry.inBundle) {
errors.push(`Missing: ${entry.name}@${entry.version} from lock file`)
}
continue
}

Expand Down
21 changes: 21 additions & 0 deletions test/lib/utils/validate-lockfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,27 @@ t.test('extra inventory items on idealTree', async t => {
)
})

t.test('missing bundled inventory items do not invalidate lockfile', async t => {
const errors = validateLockfile(
new Map([
['node_modules/bundle', { name: 'bundle', version: '1.0.0' }],
]),
new Map([
['node_modules/bundle', { name: 'bundle', version: '1.0.0' }],
['node_modules/bundle/node_modules/embedded', {
name: 'embedded',
version: '1.0.0',
inBundle: true,
}],
['node_modules/missing', { name: 'missing', version: '2.0.0' }],
])
)

t.strictSame(errors, [
'Missing: missing@2.0.0 from lock file',
], 'bundled nodes are supplied by their parent tarball, while ordinary nodes remain required')
})

t.test('extra inventory items on virtualTree', async t => {
t.matchSnapshot(
validateLockfile(
Expand Down