Skip to content

Commit 570b3eb

Browse files
AlexHickiejbedard
authored andcommitted
Fix js_run_devserver on Windows
1 parent 4f50af1 commit 570b3eb

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

js/private/js_run_devserver.mjs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -601,6 +601,12 @@ async function syncFiles(files, sandbox, writePerm, doSync) {
601601
);
602602
}
603603

604+
function isWindowsScript(tool) {
605+
const toolExtension = path.extname(tool)
606+
const isScriptFile = toolExtension === '.bat' || toolExtension === '.cmd'
607+
return isScriptFile && os.platform() === 'win32'
608+
}
609+
604610
async function main(args, sandbox) {
605611
console.error(
606612
`\n\nStarting js_run_devserver ${process.env.JS_BINARY__TARGET}`
@@ -693,6 +699,10 @@ async function runIBazelProtocol(
693699
cwd: cwd,
694700
env: env,
695701

702+
// `.cmd` and `.bat` are always executed in a shell on windows
703+
// and require the flag to be set per CVE-2024-27980
704+
shell: isWindowsScript(tool),
705+
696706
// Pipe stdin data to the child process rather than simply letting
697707
// the child process inherit the stream and consume the data itself.
698708
// If the child process consumes the data itself, then ibazel's
@@ -805,6 +815,11 @@ async function runWatchProtocol(
805815
const proc = child_process.spawn(tool, toolArgs, {
806816
cwd,
807817
env,
818+
819+
// `.cmd` and `.bat` are always executed in a shell on windows
820+
// and require the flag to be set per CVE-2024-27980
821+
shell: isWindowsScript(tool),
822+
808823
stdio: 'inherit',
809824
});
810825
proc.on('close', resolve);

0 commit comments

Comments
 (0)