返回提交历史
Modified
scripts/dev.cjs
+18
-3
XFEstudio/XFESpaceNinjaServer
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>
8d57eda9
代码差异
1 个文件
+18
-3
@@ -13,6 +13,17 @@ args.push("--dev");
13
13
args.push("--secret");
14
14
args.push(secret);
15
15
16
const cangoraw = (() => {
17
if (process.versions.bun) {
18
return true;
19
}
20
const [major, minor] = process.versions.node.split(".").map(x => parseInt(x));
21
if (major > 22 || (major == 22 && minor >= 7)) {
22
return true;
23
}
24
return false;
25
})();
26
16
27
let buildproc, runproc;
17
28
const spawnopts = { stdio: "inherit", shell: true };
18
29
function run(changedFile) {
@@ -29,7 +40,7 @@ function run(changedFile) {
29
40
runproc = undefined;
30
41
}
31
42
32
const thisbuildproc = spawn("npm", ["run", process.versions.bun ? "verify" : "build:dev"], spawnopts);
43
const thisbuildproc = spawn("npm", ["run", cangoraw ? "verify" : "build:dev"], spawnopts);
33
44
const thisbuildstart = Date.now();
34
45
buildproc = thisbuildproc;
35
46
buildproc.on("exit", code => {
@@ -38,8 +49,12 @@ function run(changedFile) {
38
49
}
39
50
buildproc = undefined;
40
51
if (code === 0) {
41
console.log(`${process.versions.bun ? "Verified" : "Built"} in ${Date.now() - thisbuildstart} ms`);
42
runproc = spawn("npm", ["run", process.versions.bun ? "raw:bun" : "start", "--", ...args], spawnopts);
52
console.log(`${cangoraw ? "Verified" : "Built"} in ${Date.now() - thisbuildstart} ms`);
53
runproc = spawn(
54
"npm",
55
["run", cangoraw ? (process.versions.bun ? "raw:bun" : "raw") : "start", "--", ...args],
56
spawnopts
57
);
43
58
runproc.on("exit", () => {
44
59
runproc = undefined;
45
60
});