Skip to content
Open
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
4 changes: 2 additions & 2 deletions internal/detector/nodescan.go
Original file line number Diff line number Diff line change
Expand Up @@ -339,11 +339,11 @@ func defaultPnpmBinDir(exec executor.Executor) string {
}
case model.PlatformLinux:
if home := exec.Getenv("HOME"); home != "" {
return filepath.Join(home, ".local", "share", "pnpm")
return filepath.Join(home, ".local", "share", "pnpm", "bin")
}
case model.PlatformWindows:
if localAppData := exec.Getenv("LOCALAPPDATA"); localAppData != "" {
return filepath.Join(localAppData, "pnpm")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Prateek-stepsecurity changes lgtm!! Can you apply similar fix for linux as well.

return filepath.Join(localAppData, "pnpm", "bin")
}
}
return ""
Expand Down
11 changes: 6 additions & 5 deletions internal/detector/nodescan_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,9 +252,10 @@ func TestNodeScanner_ScanPnpmGlobal_RootGFallback(t *testing.T) {
}
}

// TestDefaultPnpmBinDir pins pnpm's per-platform global bin-dir layout. macOS
// uses a /bin subdirectory; Linux and Windows place global binaries directly
// in PNPM_HOME (no /bin). This asymmetry matches pnpm's own `pnpm setup`.
// TestDefaultPnpmBinDir pins pnpm's per-platform global bin-dir layout.
// pnpm v11 places global shims under a /bin subdirectory on macOS, Linux,
// and Windows alike. This matches pnpm's own `pnpm setup` output: the error
// it emits names "<PNPM_HOME>/bin" as the dir that must be on PATH.
func TestDefaultPnpmBinDir(t *testing.T) {
tests := []struct {
name string
Expand All @@ -275,10 +276,10 @@ func TestDefaultPnpmBinDir(t *testing.T) {
want: "",
},
{
name: "linux with HOME → no bin suffix",
name: "linux with HOME → bin subdir",
goos: "linux",
envs: map[string]string{"HOME": "/home/foo"},
want: "/home/foo/.local/share/pnpm",
want: "/home/foo/.local/share/pnpm/bin",
},
{
name: "linux without HOME → empty",
Expand Down
Loading