MCPcopy Create free account
hub / github.com/krausest/js-framework-benchmark / getVersionFromPackageLock

Function getVersionFromPackageLock

cli/update-frameworks.js:64–80  ·  view source on GitHub ↗
(packageJSONLockPath, packageNames)

Source from the content-addressed store, hash-verified

62const frameworksCache = new Map();
63
64function getVersionFromPackageLock(packageJSONLockPath, packageNames) {
65 if (!fs.existsSync(packageJSONLockPath)) {
66 throw new Error(`package-lock.json not found at ${packageJSONLockPath}`);
67 }
68
69 let versions = {};
70
71 for (let packageName of packageNames) {
72 const packageLockJSON = JSON.parse(fs.readFileSync(packageJSONLockPath, "utf8"));
73 const packageVersion =
74 packageLockJSON.dependencies?.[packageName]?.version ||
75 packageLockJSON.packages?.[`node_modules/${packageName}`]?.version ||
76 "ERROR: Not found in package-lock";
77 versions[packageName] = packageVersion;
78 }
79 return versions;
80}
81
82function shouldUpdate(packageJSONLockPath, packageNames, DEBUG) {
83 let versions = getVersionFromPackageLock(packageJSONLockPath, packageNames);

Callers 1

shouldUpdateFunction · 0.85

Calls 1

parseMethod · 0.45

Tested by

no test coverage detected