Skip to content

Commit a827c93

Browse files
authored
feat: add pnpm to path after installation (#5465)
1 parent 0d9b4ac commit a827c93

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

pkg/npm/package_manager.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package npm
22

33
import (
44
"fmt"
5+
"os"
56
"path/filepath"
67

78
"github.com/SAP/jenkins-library/pkg/log"
@@ -52,6 +53,13 @@ func (pm *PackageManager) InstallPnpm(execRunner ExecRunner, pnpmVersion string,
5253
if err := execRunner.RunExecutable("npm", "install", pnpmPackage, "--prefix", prefixPath); err != nil {
5354
return fmt.Errorf("failed to install pnpm locally: %w", err)
5455
}
56+
57+
// Add the local pnpm bin directory to PATH so it's globally available
58+
pnpmBinDir := filepath.Join(prefixPath, "node_modules", ".bin")
59+
currentPath := os.Getenv("PATH")
60+
newPath := pnpmBinDir + string(os.PathListSeparator) + currentPath
61+
os.Setenv("PATH", newPath)
62+
5563
return nil
5664
}
5765

0 commit comments

Comments
 (0)