MCPcopy Index your code
hub / github.com/nodejs/node / validateLockfile

Function validateLockfile

deps/npm/lib/utils/validate-lockfile.js:7–27  ·  view source on GitHub ↗
(virtualTree, idealTree)

Source from the content-addressed store, hash-verified

5// Returns empty array if no errors found or an array populated
6// with an entry for each validation error found.
7function validateLockfile (virtualTree, idealTree) {
8 const errors = []
9
10 // loops through the inventory of packages resulted by ideal tree,
11 // for each package compares the versions with the version stored in the
12 // package-lock and adds an error to the list in case of mismatches
13 for (const [key, entry] of idealTree.entries()) {
14 const lock = virtualTree.get(key)
15
16 if (!lock) {
17 errors.push(`Missing: ${entry.name}@${entry.version} from lock file`)
18 continue
19 }
20
21 if (entry.version !== lock.version) {
22 errors.push(`Invalid: lock file's ${lock.name}@${lock.version} does ` +
23 `not satisfy ${entry.name}@${entry.version}`)
24 }
25 }
26 return errors
27}
28
29module.exports = validateLockfile

Callers 2

execMethod · 0.85

Calls 3

getMethod · 0.65
entriesMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…