|
1 | 1 | import { EOL } from "os";
|
2 | 2 | import os from 'os';
|
3 |
| -import { execFileSync, execSync } from "child_process"; |
| 3 | +import { execFileSync } from "child_process"; |
4 | 4 |
|
5 | 5 | export const RegexNotToBeLogged = /EXHORT_.*_TOKEN|ex-.*-token/
|
6 | 6 | /**
|
@@ -126,12 +126,14 @@ export function getGitRootDir(cwd) {
|
126 | 126 | * @returns {string}
|
127 | 127 | */
|
128 | 128 | export function invokeCommand(bin, args, opts={}) {
|
129 |
| - // .bat and .cmd files can't be executed in windows with execFileSync, so we special case them |
130 |
| - // to use execSync here to keep the amount of escaping we need to do to a minimum. |
| 129 | + // .bat and .cmd files can't be executed in windows with execFileSync without {shell: true}, so we |
| 130 | + // special case them here to keep the amount of escaping we need to do to a minimum. |
131 | 131 | // https://nodejs.org/docs/latest-v20.x/api/child_process.html#spawning-bat-and-cmd-files-on-windows
|
132 |
| - if (process.platform === 'win32' && (bin.endsWith(".bat") || bin.endsWith(".cmd"))) { |
| 132 | + // https://github.com/nodejs/node/issues/52681#issuecomment-2076426887 |
| 133 | + if (process.platform === 'win32') { |
| 134 | + opts = {...opts, shell: true} |
133 | 135 | args = args.map(arg => handleSpacesInPath(arg))
|
134 |
| - return execSync(`${handleSpacesInPath(bin)} ${args.join(" ")}`, {...{stdio: 'pipe', encoding: 'utf-8'}, ...opts}) |
| 136 | + bin = handleSpacesInPath(bin) |
135 | 137 | }
|
136 | 138 |
|
137 | 139 | return execFileSync(bin, args, {...{stdio: 'pipe', encoding: 'utf-8'}, ...opts})
|
|
0 commit comments