diff --git a/js/hardware.js b/js/hardware.js index 80b9c80..96d70d6 100644 --- a/js/hardware.js +++ b/js/hardware.js @@ -798,24 +798,24 @@ const execAsyncCommand = (cmd, args = [], callback = null) => { * @returns {Object} The spawned process object. */ const execScriptCommand = (cmd, args = [], callback = null) => { - let progress = 10; + let progress = 1; let proc = cpr.spawn(cmd, args); if (typeof callback === "function") callback(progress, null); proc.stdout.on("data", (data) => { if (data) { - const lines = data.toString().trim(); - const output = lines.replace(/\n+/g, "\n").replace(/^\n+|\n+$|\0/g, ""); - if (output) { - console.log(output); + const output = data.toString().trim(); + const lines = output.replace(/\n+/g, "\n").replace(/^\n+|\n+$|\0/g, ""); + for (const line of lines.split("\n").filter(Boolean)) { + console.log(line); } } }); proc.stderr.on("data", (data) => { if (data) { - const lines = data.toString().trim(); - const output = lines.replace(/\n+/g, "\n").replace(/^\n+|\n+$|\0/g, ""); - if (output) { - const matches = output.match(/(\d{1,3})%/g); + const output = data.toString().trim(); + const lines = output.replace(/\n+/g, "\n").replace(/^\n+|\n+$|\0/g, ""); + for (const line of lines.split("\n").filter(Boolean)) { + const matches = line.match(/(\d{1,3})%/g); if (matches) { const match = Math.max(...matches.map((p) => parseInt(p))); const percent = Math.floor(match / 10) * 10; diff --git a/js/integration.js b/js/integration.js index 107a3b6..9b23e4a 100644 --- a/js/integration.js +++ b/js/integration.js @@ -209,6 +209,9 @@ const initApp = () => { hardware.setDisplayStatus("ON"); const args = ["-c", `bash <(wget -qO- ${APP.scripts.install}) update`]; hardware.execScriptCommand("bash", args, (progress, error) => { + if (progress) { + console.log(`Progress: ${progress}%`); + } updateApp(progress); }); } diff --git a/js/webview.js b/js/webview.js index 295a83a..c04a213 100644 --- a/js/webview.js +++ b/js/webview.js @@ -783,13 +783,6 @@ const viewEvents = async () => { * Register app events and handler. */ const appEvents = async () => { - // Handle signal and exit events - process.on("SIGINT", app.quit); - app.on("before-quit", () => { - WEBVIEW.tracker.status = "Terminated"; - integration.update(); - }); - // Handle multiple instances app.on("second-instance", () => { if (WEBVIEW.window.isMinimized()) { @@ -798,6 +791,14 @@ const appEvents = async () => { WEBVIEW.window.focus(); }); + // Handle signal and exit events + app.on("before-quit", () => { + WEBVIEW.tracker.status = "Terminated"; + console.warn(`${APP.title} Terminated`); + integration.update(); + }); + process.on("SIGINT", app.quit); + // Webview initialized WEBVIEW.initialized = true;