From 8d57eda9d2b6f876e158644c7b3411ca2a6fc2c9 Mon Sep 17 00:00:00 2001 From: Sainan <63328889+Sainan@users.noreply.github.com> Date: Wed, 3 Sep 2025 22:46:03 -0700 Subject: [PATCH] chore: make use of raw running when dev script is used with newer node (#2748) Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/2748 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com> --- scripts/dev.cjs | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/scripts/dev.cjs b/scripts/dev.cjs index 7931df6b..fad64aba 100644 --- a/scripts/dev.cjs +++ b/scripts/dev.cjs @@ -13,6 +13,17 @@ args.push("--dev"); args.push("--secret"); args.push(secret); +const cangoraw = (() => { + if (process.versions.bun) { + return true; + } + const [major, minor] = process.versions.node.split(".").map(x => parseInt(x)); + if (major > 22 || (major == 22 && minor >= 7)) { + return true; + } + return false; +})(); + let buildproc, runproc; const spawnopts = { stdio: "inherit", shell: true }; function run(changedFile) { @@ -29,7 +40,7 @@ function run(changedFile) { runproc = undefined; } - const thisbuildproc = spawn("npm", ["run", process.versions.bun ? "verify" : "build:dev"], spawnopts); + const thisbuildproc = spawn("npm", ["run", cangoraw ? "verify" : "build:dev"], spawnopts); const thisbuildstart = Date.now(); buildproc = thisbuildproc; buildproc.on("exit", code => { @@ -38,8 +49,12 @@ function run(changedFile) { } buildproc = undefined; if (code === 0) { - console.log(`${process.versions.bun ? "Verified" : "Built"} in ${Date.now() - thisbuildstart} ms`); - runproc = spawn("npm", ["run", process.versions.bun ? "raw:bun" : "start", "--", ...args], spawnopts); + console.log(`${cangoraw ? "Verified" : "Built"} in ${Date.now() - thisbuildstart} ms`); + runproc = spawn( + "npm", + ["run", cangoraw ? (process.versions.bun ? "raw:bun" : "raw") : "start", "--", ...args], + spawnopts + ); runproc.on("exit", () => { runproc = undefined; });