Skip to content

Commit 93b15d6

Browse files
authored
Add shell: true to execFile for npm hover (microsoft#224585)
* Add shell: true to execFile for npm hover Fixes microsoft#224510 * Use shell: true only on Windows
1 parent b1c0a14 commit 93b15d6

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

extensions/npm/src/features/packageJSONContribution.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,13 @@ export class PackageJSONContribution implements IJSONContribution {
293293
// COREPACK_ENABLE_PROJECT_SPEC makes the npm view command succeed
294294
// even if packageManager specified a package manager other than npm.
295295
const env = { ...process.env, COREPACK_ENABLE_AUTO_PIN: '0', COREPACK_ENABLE_PROJECT_SPEC: '0' };
296-
cp.execFile(npmCommandPath, args, { cwd, env }, (error, stdout) => {
296+
let options: cp.ExecFileOptions = { cwd, env };
297+
let commandPath: string = npmCommandPath;
298+
if (process.platform === 'win32') {
299+
options = { cwd, env, shell: true };
300+
commandPath = `"${npmCommandPath}"`;
301+
}
302+
cp.execFile(commandPath, args, options, (error, stdout) => {
297303
if (!error) {
298304
try {
299305
const content = JSON.parse(stdout);

0 commit comments

Comments
 (0)