@kushankurdas/npm-sentinel 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/parse-npm-lockfile.js +16 -3
- package/package.json +1 -1
|
@@ -77,10 +77,23 @@ function parseLockfileV2(lock, lockfileVersion) {
|
|
|
77
77
|
for (const [pathKey, pkg] of Object.entries(map)) {
|
|
78
78
|
if (pathKey === "") continue;
|
|
79
79
|
if (!pkg || typeof pkg !== "object") continue;
|
|
80
|
-
|
|
80
|
+
let version = pkg.version;
|
|
81
|
+
let name = pkg.name || pathKeyToPackageName(pathKey);
|
|
82
|
+
let depRecord = pkg.dependencies || {};
|
|
83
|
+
|
|
84
|
+
// npm lockfile v2/v3 can represent local file/workspace deps as links:
|
|
85
|
+
// "node_modules/@scope/pkg": { "resolved": "pkg-dir", "link": true }
|
|
86
|
+
// and store the actual version/deps at "pkg-dir".
|
|
87
|
+
if (!version && pkg.link === true && typeof pkg.resolved === "string") {
|
|
88
|
+
const target = map[pkg.resolved];
|
|
89
|
+
if (target && typeof target === "object" && target.version) {
|
|
90
|
+
version = target.version;
|
|
91
|
+
name = target.name || name;
|
|
92
|
+
depRecord = target.dependencies || {};
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
81
96
|
if (!version) continue;
|
|
82
|
-
const name = pkg.name || pathKeyToPackageName(pathKey);
|
|
83
|
-
const depRecord = pkg.dependencies || {};
|
|
84
97
|
const directDependencyNames = Object.keys(depRecord);
|
|
85
98
|
packages.push({
|
|
86
99
|
path: pathKey.replace(/\\/g, "/"),
|