Skip to content

Commit 1229989

Browse files
jfcherngskovhus
authored andcommitted
fix: default shell on Windows should be cmd.exe
Signed-off-by: Jack Cherng <jfcherng@gmail.com>
1 parent 28f5659 commit 1229989

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

server/src/util/sh.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,22 @@
11
import * as ChildProcess from 'child_process'
22

3+
import { isWindows } from './platform'
4+
35
/**
46
* Execute the following sh program.
57
*/
6-
export function execShellScript(body: string, cmd = 'bash'): Promise<string> {
7-
const args = ['-c', body]
8+
export function execShellScript(
9+
body: string,
10+
cmd = isWindows() ? 'cmd.exe' : 'bash',
11+
): Promise<string> {
12+
const args = []
13+
14+
if (cmd === 'cmd.exe') {
15+
args.push('/c', body)
16+
} else {
17+
args.push('-c', body)
18+
}
19+
820
const process = ChildProcess.spawn(cmd, args)
921

1022
return new Promise((resolve, reject) => {

0 commit comments

Comments
 (0)