Skip to content
This repository was archived by the owner on Mar 18, 2025. It is now read-only.

Commit 1ce01eb

Browse files
committed
update livereload script
1 parent d9b9bbb commit 1ce01eb

File tree

3 files changed

+30
-8
lines changed

3 files changed

+30
-8
lines changed

demo/livereload.js

Lines changed: 29 additions & 0 deletions
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();

demo/livereload.sh

Lines changed: 0 additions & 7 deletions
This file was deleted.

demo/package.json

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

0 commit comments

Comments
 (0)