Skip to content

Commit 4301be5

Browse files
authored
Merge pull request #2 from jonasgrunert/master
Remove reliance on .sh script
2 parents 54ed0b0 + 1d0f0e2 commit 4301be5

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

livereload.js

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/usr/bin/env node
2+
const { spawn } = require("child_process");
3+
const { normalize } = require("path");
4+
5+
// 'disconnect' is not needed as it will only be raised, when either the child process or this process calss disconnect explicitly.
6+
// We are abel to ensure, that this will never happen, as we do not need communication with the spawned subprocess
7+
const terminationSignals = ["close", "exit"];
8+
9+
function startSubprocess() {
10+
return new Promise((res, rej) => {
11+
const [command, ...args] = process.argv.slice(2);
12+
const proc = spawn(normalize(command), args, {
13+
// use parents stdio
14+
stdio: "inherit",
15+
shell:
16+
process.platform === "win32" ||
17+
/^(msys|cygwin)$/.test(process.env.OSTYPE),
18+
});
19+
terminationSignals.forEach((event) => proc.on(event, res));
20+
proc.on("error", rej);
21+
});
22+
}
23+
24+
async function loop() {
25+
let code = 64;
26+
while (code === 64) code = await startSubprocess();
27+
}
28+
29+
loop();

package.json

+1-1
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)