Skip to content
Merged
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
15 changes: 10 additions & 5 deletions internal/npm/npm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -689,20 +689,25 @@ func TestPnpmLockV9(t *testing.T) {
t.Fatalf("Parse failed: %v", err)
}

if len(deps) != 3 {
t.Fatalf("expected 3 dependencies, got %d", len(deps))
if len(deps) != 90 {
t.Fatalf("expected 90 dependencies, got %d", len(deps))
}

depMap := make(map[string]core.Dependency)
for _, d := range deps {
depMap[d.Name] = d
}

// All 3 packages
// Sample of packages
expected := map[string]string{
"@babel/helper-string-parser": "7.27.1",
"@babel/helper-string-parser": "7.27.1",
"@babel/helper-validator-identifier": "7.27.1",
"@babel/types": "7.28.1",
"@babel/types": "7.28.1",
"babel": "4.7.16",
"mocha": "2.5.3",
"zod": "3.24.2",
"acorn": "5.7.4",
"esprima-fb": "15001.1001.0-dev-harmony-fb",
}

for name, wantVer := range expected {
Expand Down
5 changes: 3 additions & 2 deletions internal/npm/pnpm.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ func extractPnpmPackageKey(line string) (string, bool) {
if len(key) >= 2 && (key[0] == '\'' || key[0] == '"') {
key = key[1 : len(key)-1]
}
// Must start with / or @
if len(key) == 0 || (key[0] != '/' && key[0] != '@') {
// v5 format starts with /, scoped v6+ starts with @,
// non-scoped v6+ (e.g. "acorn@5.7.4") must contain @ as version separator
if len(key) == 0 || (key[0] != '/' && key[0] != '@' && !strings.Contains(key, "@")) {
return "", false
}
return key, true
Expand Down