Skip to content

Commit a41a41a

Browse files
committed
allow concurrency
1 parent 2e28c4b commit a41a41a

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

rescript

+12-2
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,9 @@ var maybe_subcommand = process_argv[2];
170170
var is_building = false;
171171
function releaseBuild() {
172172
if (is_building) {
173+
try {
174+
fs.unlinkSync(lockFileName);
175+
} catch (err) {}
173176
is_building = false;
174177
}
175178
}
@@ -180,8 +183,15 @@ function acquireBuild() {
180183
if (is_building) {
181184
return false;
182185
} else {
183-
is_building = true;
184-
return true;
186+
try {
187+
fs.openSync(lockFileName, "wx", 0o664);
188+
is_building = true;
189+
} catch (err) {
190+
if (err.code === "EEXIST") {
191+
console.warn(lockFileName, "already exists, try later");
192+
} else console.log(err);
193+
}
194+
return is_building;
185195
}
186196
}
187197

0 commit comments

Comments
 (0)