No need to debounce, simply ignore orphaned build process "exit" events
All checks were successful
Build / build (pull_request) Successful in 50s
All checks were successful
Build / build (pull_request) Successful in 50s
This commit is contained in:
parent
befbe820b4
commit
4c0d804828
@ -13,7 +13,7 @@ args.push("--dev");
|
|||||||
args.push("--secret");
|
args.push("--secret");
|
||||||
args.push(secret);
|
args.push(secret);
|
||||||
|
|
||||||
let buildproc, runproc, timeout;
|
let buildproc, runproc;
|
||||||
function run(changedFile) {
|
function run(changedFile) {
|
||||||
if (changedFile) {
|
if (changedFile) {
|
||||||
console.log(`Change to ${changedFile} detected`);
|
console.log(`Change to ${changedFile} detected`);
|
||||||
@ -28,10 +28,12 @@ function run(changedFile) {
|
|||||||
runproc = undefined;
|
runproc = undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
clearTimeout(timeout);
|
const thisbuildproc = spawn("npm", ["run", "build:dev"], { stdio: "inherit", shell: true });
|
||||||
timeout = setTimeout(function () {
|
buildproc = thisbuildproc;
|
||||||
buildproc = spawn("npm", ["run", "build:dev"], { stdio: "inherit", shell: true });
|
|
||||||
buildproc.on("exit", code => {
|
buildproc.on("exit", code => {
|
||||||
|
if (buildproc !== thisbuildproc) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
buildproc = undefined;
|
buildproc = undefined;
|
||||||
if (code === 0) {
|
if (code === 0) {
|
||||||
runproc = spawn("npm", ["run", "start", "--", ...args], { stdio: "inherit", shell: true });
|
runproc = spawn("npm", ["run", "start", "--", ...args], { stdio: "inherit", shell: true });
|
||||||
@ -40,7 +42,6 @@ function run(changedFile) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}, 20);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
run();
|
run();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user