chore: make use of raw running when dev script is used with newer node #2748
@ -13,6 +13,17 @@ args.push("--dev");
|
|||||||
args.push("--secret");
|
args.push("--secret");
|
||||||
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;
|
let buildproc, runproc;
|
||||||
const spawnopts = { stdio: "inherit", shell: true };
|
const spawnopts = { stdio: "inherit", shell: true };
|
||||||
function run(changedFile) {
|
function run(changedFile) {
|
||||||
@ -29,7 +40,7 @@ function run(changedFile) {
|
|||||||
runproc = undefined;
|
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();
|
const thisbuildstart = Date.now();
|
||||||
buildproc = thisbuildproc;
|
buildproc = thisbuildproc;
|
||||||
buildproc.on("exit", code => {
|
buildproc.on("exit", code => {
|
||||||
@ -38,8 +49,12 @@ function run(changedFile) {
|
|||||||
}
|
}
|
||||||
buildproc = undefined;
|
buildproc = undefined;
|
||||||
if (code === 0) {
|
if (code === 0) {
|
||||||
console.log(`${process.versions.bun ? "Verified" : "Built"} in ${Date.now() - thisbuildstart} ms`);
|
console.log(`${cangoraw ? "Verified" : "Built"} in ${Date.now() - thisbuildstart} ms`);
|
||||||
runproc = spawn("npm", ["run", process.versions.bun ? "raw:bun" : "start", "--", ...args], spawnopts);
|
runproc = spawn(
|
||||||
|
"npm",
|
||||||
|
["run", cangoraw ? (process.versions.bun ? "raw:bun" : "raw") : "start", "--", ...args],
|
||||||
|
spawnopts
|
||||||
|
);
|
||||||
runproc.on("exit", () => {
|
runproc.on("exit", () => {
|
||||||
runproc = undefined;
|
runproc = undefined;
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user