Skip to content

Commit

Permalink
fix(spawn): add shell:true on windows (#4985)
Browse files Browse the repository at this point in the history
Closes neoclide/coc-prettier#178

Latest version of Node.js needs to set `shell: true` to spawn option

- node-red/node-red#4652
- microsoft/rushstack#4637
  • Loading branch information
fannheyward authored Apr 19, 2024
1 parent 2f31237 commit 77ae2d4
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/extension/installer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ export class Installer extends EventEmitter implements IInstaller {
this.log(`Installing dependencies by: ${this.npm} ${args.join(' ')}.`)
const child = child_process.spawn(this.npm, args, {
cwd: folder,
shell: process.platform === 'win32',
env: Object.assign(process.env, { NODE_ENV: 'production' })
})
this.readLines('[npm stdout]', child.stdout)
Expand Down
2 changes: 1 addition & 1 deletion src/handler/refactor/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const controlCode = '\x1b'
class Task extends EventEmitter {
private process: ChildProcess
public start(cmd: string, args: string[], cwd: string): void {
this.process = spawn(cmd, args, { cwd })
this.process = spawn(cmd, args, { cwd, shell: process.platform === 'win32' })
this.process.on('error', e => {
this.emit('error', e.message)
})
Expand Down
2 changes: 1 addition & 1 deletion src/list/commandTask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export default class CommandTask extends EventEmitter implements ListTask {

private start(): void {
let { cmd, args, cwd, onLine } = this.opt
let proc = spawn(cmd, args, { cwd: cwd || workspace.cwd, windowsHide: true })
let proc = spawn(cmd, args, { cwd: cwd || workspace.cwd, windowsHide: true, shell: process.platform === 'win32' })
this.disposables.push({
dispose: () => {
proc.kill()
Expand Down

0 comments on commit 77ae2d4

Please sign in to comment.