fix: the env command on Windows (#3742)

close #3711
This commit is contained in:
Zoltan Kochan
2021-09-03 03:37:22 +03:00
committed by GitHub
parent 52620a4266
commit 869b1afcbe
2 changed files with 9 additions and 3 deletions

View File

@@ -0,0 +1,5 @@
---
"@pnpm/plugin-commands-env": patch
---
Do not create powershell command shims for node, npm, and npx.

View File

@@ -65,15 +65,16 @@ export async function handler (opts: NvmNodeCommandOptions, params: string[]) {
})
const src = path.join(nodeDir, process.platform === 'win32' ? 'node.exe' : 'bin/node')
const dest = path.join(opts.bin, 'node')
await cmdShim(src, dest)
const cmdShimOpts = { createPwshFile: false }
await cmdShim(src, dest, cmdShimOpts)
try {
let npmDir = nodeDir
if (process.platform !== 'win32') {
npmDir = path.join(npmDir, 'lib')
}
npmDir = path.join(npmDir, 'node_modules/npm/bin')
await cmdShim(path.join(npmDir, 'npm-cli.js'), path.join(opts.bin, 'npm'))
await cmdShim(path.join(npmDir, 'npx-cli.js'), path.join(opts.bin, 'npx'))
await cmdShim(path.join(npmDir, 'npm-cli.js'), path.join(opts.bin, 'npm'), cmdShimOpts)
await cmdShim(path.join(npmDir, 'npx-cli.js'), path.join(opts.bin, 'npx'), cmdShimOpts)
} catch (err) {
// ignore
}