Skip to content

Commit ba082e8

Browse files
committed
Replacing bash file with node
This should enable cross-plattform development easily, while not requiring any special setups.
1 parent a85bf85 commit ba082e8

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

livereload.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/usr/bin/env node
2+
const { spawn } = require("child_process");
3+
const { normalize } = require("path");
4+
5+
const termiateSignals = ["close", "exit", ""];
6+
7+
function startSubprocess() {
8+
return new Promise((res, rej) => {
9+
const proc = spawn(process.argv.slice(2).map(normalize).join(" "), {
10+
stdio: ["pipe", "pipe", "pipe"],
11+
shell:
12+
process.platform === "win32" ||
13+
/^(msys|cygwin)$/.test(process.env.OSTYPE),
14+
});
15+
proc.stdout.pipe(process.stdout);
16+
proc.stderr.pipe(process.stderr);
17+
process.stdin.pipe(proc.stdin);
18+
termiateSignals.forEach((e) => proc.on(e, res));
19+
proc.on("error", rej);
20+
});
21+
}
22+
23+
async function loop() {
24+
let code = 64;
25+
while (code === 64) code = await startSubprocess();
26+
}
27+
28+
loop();

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"scripts": {
99
"build": "webpack --mode production",
1010
"dev": "webpack --mode=development",
11-
"start": "./livereload.sh node_modules/.bin/qode ./dist/index.js",
11+
"start": "node livereload.js node_modules/.bin/qode ./dist/index.js",
1212
"debug": "qode --inspect ./dist/index.js"
1313
},
1414
"dependencies": {

0 commit comments

Comments
 (0)