Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove reliance on .sh script #2

Merged
merged 4 commits into from
Apr 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions livereload.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env node
const { spawn } = require("child_process");
const { normalize } = require("path");

// 'disconnect' is not needed as it will only be raised, when either the child process or this process calss disconnect explicitly.
// We are abel to ensure, that this will never happen, as we do not need communication with the spawned subprocess
const terminationSignals = ["close", "exit"];

function startSubprocess() {
return new Promise((res, rej) => {
const [command, ...args] = process.argv.slice(2);
const proc = spawn(normalize(command), args, {
// use parents stdio
stdio: "inherit",
shell:
process.platform === "win32" ||
/^(msys|cygwin)$/.test(process.env.OSTYPE),
});
terminationSignals.forEach((event) => proc.on(event, res));
proc.on("error", rej);
});
}

async function loop() {
let code = 64;
while (code === 64) code = await startSubprocess();
}

loop();
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"scripts": {
"build": "webpack --mode production",
"dev": "webpack --mode=development",
"start": "./livereload.sh node_modules/.bin/qode ./dist/index.js",
"start": "node livereload.js node_modules/.bin/qode ./dist/index.js",
"debug": "qode --inspect ./dist/index.js"
},
"dependencies": {
Expand Down