fix: linking bins inside a workspace

close #2925
PR #2929
This commit is contained in:
Zoltan Kochan
2020-10-15 11:14:58 +03:00
committed by GitHub
parent 08d1ef3623
commit fb863fae43
2 changed files with 10 additions and 1 deletions

View File

@@ -0,0 +1,5 @@
---
"@pnpm/link-bins": patch
---
When creating command shims, add the parent node_modules directory of the `.bin` directory to the NODE_PATH.

View File

@@ -159,7 +159,11 @@ async function linkBin (cmd: Command, binsDir: string) {
if (EXECUTABLE_SHEBANG_SUPPORTED) {
await fs.chmod(cmd.path, 0o755)
}
const nodePath = await getBinNodePaths(cmd.path)
let nodePath = await getBinNodePaths(cmd.path)
const binsParentDir = path.dirname(binsDir)
if (path.relative(cmd.path, binsParentDir) !== '') {
nodePath = R.union(nodePath, await getBinNodePaths(binsParentDir))
}
return cmdShim(cmd.path, externalBinPath, {
createPwshFile: POWER_SHELL_IS_SUPPORTED,
nodePath,