Use shell: true only on Windows (#224597)

This commit is contained in:
Alex Ross
2024-08-05 10:46:45 +02:00
committed by GitHub
parent dad736b252
commit 789d5fe04e

View File

@@ -293,7 +293,13 @@ export class PackageJSONContribution implements IJSONContribution {
// COREPACK_ENABLE_PROJECT_SPEC makes the npm view command succeed
// even if packageManager specified a package manager other than npm.
const env = { ...process.env, COREPACK_ENABLE_AUTO_PIN: '0', COREPACK_ENABLE_PROJECT_SPEC: '0' };
cp.execFile(`"${npmCommandPath}"`, args, { cwd, env, shell: true }, (error, stdout) => {
let options: cp.ExecFileOptions = { cwd, env };
let commandPath: string = npmCommandPath;
if (process.platform === 'win32') {
options = { cwd, env, shell: true };
commandPath = `"${npmCommandPath}"`;
}
cp.execFile(commandPath, args, options, (error, stdout) => {
if (!error) {
try {
const content = JSON.parse(stdout);