From de144bc0cb699014c6b310dffa466230880b0a3f Mon Sep 17 00:00:00 2001 From: DoSun Date: Thu, 7 May 2026 16:36:35 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20Windows=20=E4=B8=8B?= =?UTF-8?q?=20dev=20serve=20=E6=A8=A1=E5=BC=8F=20Ctrl+C=20=E6=97=A0?= =?UTF-8?q?=E6=B3=95=E5=85=B3=E9=97=AD=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/dev.ts | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/scripts/dev.ts b/scripts/dev.ts index 974334c19..1e4fc6abf 100644 --- a/scripts/dev.ts +++ b/scripts/dev.ts @@ -73,9 +73,26 @@ const inspectArgs = process.env.BUN_INSPECT // npm, etc.) and on all platforms. const bunCmd = process.execPath; -const result = Bun.spawnSync( - [bunCmd, ...inspectArgs, "run", ...defineArgs, ...featureArgs, cliPath, ...process.argv.slice(2)], - { stdio: ["inherit", "inherit", "inherit"], cwd: projectRoot }, -); +const args = [bunCmd, ...inspectArgs, "run", ...defineArgs, ...featureArgs, cliPath, ...process.argv.slice(2)]; -process.exit(result.exitCode ?? 0); +if (process.platform === "win32") { + const child = Bun.spawn(args, { + stdio: ["inherit", "inherit", "inherit"], + cwd: projectRoot, + onExit(proc, exitCode) { + process.exit(exitCode ?? 0); + }, + }); + const cleanup = (sig: string) => { + child.kill(sig as Bun.Signal); + setTimeout(() => process.exit(1), 3000); + }; + process.on("SIGINT", () => cleanup("SIGINT")); + process.on("SIGTERM", () => cleanup("SIGTERM")); +} else { + const result = Bun.spawnSync(args, { + stdio: ["inherit", "inherit", "inherit"], + cwd: projectRoot, + }); + process.exit(result.exitCode ?? 0); +}