Skip to content

Commit f57c4b7

Browse files
committed
fix watch build
1 parent 2d98261 commit f57c4b7

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

scripts/rescript_bsb.js

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,16 @@ function releaseBuild() {
2828
* lock files shouldn't rely on the umask to disallow tampering by other.
2929
*
3030
* @param {Array<string>} args
31+
* @param {child_process.SpawnOptions} [options]
3132
*/
32-
function acquireBuild(args) {
33+
function acquireBuild(args, options) {
3334
if (ownerProcess) {
3435
return null;
3536
} else {
3637
try {
3738
ownerProcess = child_process.spawn(rescript_exe, args, {
3839
stdio: "inherit",
40+
...options,
3941
});
4042
fs.writeFileSync(lockFileName, ownerProcess.pid.toString(), {
4143
encoding: "utf8",
@@ -370,17 +372,17 @@ Please pick a different one using the \`-ws [host:]port\` flag from bsb.`);
370372
} else {
371373
dlog(`Rebuilding since ${reasonsToRebuild}`);
372374
}
373-
if (acquireBuild(args)) {
375+
let p;
376+
if (
377+
(p = acquireBuild(rescriptWatchBuildArgs, {
378+
stdio: ["inherit", "inherit", "pipe"],
379+
}))
380+
) {
374381
logStartCompiling();
375-
child_process
376-
.spawn(rescript_exe, rescriptWatchBuildArgs, {
377-
stdio: ["inherit", "inherit", "pipe"],
378-
})
379-
// @ts-ignore
380-
.on("data", function (s) {
381-
outputError(s, "ninja: error");
382-
})
383-
.on("exit", buildFinishedCallback)
382+
p.on("data", function (s) {
383+
outputError(s, "ninja: error");
384+
})
385+
.once("exit", buildFinishedCallback)
384386
.stderr.setEncoding("utf8");
385387
// This is important to clean up all
386388
// previous queued events

0 commit comments

Comments
 (0)