@hyrious/dup
Advanced tools
Comparing version 0.1.4 to 0.1.5
@@ -17,2 +17,3 @@ // src/dup.ts | ||
function dup_packages(p) { | ||
const isNPM = !!p[""]; | ||
const collected = []; | ||
@@ -22,3 +23,3 @@ for (const key in p) { | ||
let ver; | ||
if (key.startsWith("node_modules/")) { | ||
if (isNPM && key) { | ||
const parts = key.split("/").slice(-2); | ||
@@ -28,5 +29,7 @@ if (parts[0][0] === "@") { | ||
} else { | ||
pkg = parts[1]; | ||
pkg = parts.pop(); | ||
} | ||
ver = p[key].version; | ||
if (ver == null) | ||
continue; | ||
collected.push([pkg, ver]); | ||
@@ -33,0 +36,0 @@ } else if (key) { |
{ | ||
"name": "@hyrious/dup", | ||
"type": "module", | ||
"version": "0.1.4", | ||
"version": "0.1.5", | ||
"description": "Find duplicates in your lockfile", | ||
@@ -6,0 +6,0 @@ "author": "hyrious <hyrious@outlook.com>", |
@@ -38,2 +38,3 @@ /** | ||
function dup_packages(p: { readonly [key: string]: unknown }) { | ||
const isNPM = !!p[""]; | ||
const collected: [pkg: string, ver: string][] = []; | ||
@@ -45,3 +46,3 @@ for (const key in p) { | ||
// NPM: "node_modules/path/to/{package-name}": { "version": {version} } | ||
if (key.startsWith("node_modules/")) { | ||
if (isNPM && key) { | ||
const parts = key.split("/").slice(-2); | ||
@@ -51,5 +52,6 @@ if (parts[0][0] === "@") { | ||
} else { | ||
pkg = parts[1]; | ||
pkg = parts.pop()!; | ||
} | ||
ver = (p[key] as { version: string }).version; | ||
if (ver == null) continue; | ||
collected.push([pkg, ver]); | ||
@@ -56,0 +58,0 @@ } |
15175
377