ref: add console logs

This commit is contained in:
leukipp
2025-09-08 20:03:23 +02:00
parent b5e95936dc
commit 7267fafb97
3 changed files with 20 additions and 16 deletions
+9 -9
View File
@@ -798,24 +798,24 @@ const execAsyncCommand = (cmd, args = [], callback = null) => {
* @returns {Object} The spawned process object. * @returns {Object} The spawned process object.
*/ */
const execScriptCommand = (cmd, args = [], callback = null) => { const execScriptCommand = (cmd, args = [], callback = null) => {
let progress = 10; let progress = 1;
let proc = cpr.spawn(cmd, args); let proc = cpr.spawn(cmd, args);
if (typeof callback === "function") callback(progress, null); if (typeof callback === "function") callback(progress, null);
proc.stdout.on("data", (data) => { proc.stdout.on("data", (data) => {
if (data) { if (data) {
const lines = data.toString().trim(); const output = data.toString().trim();
const output = lines.replace(/\n+/g, "\n").replace(/^\n+|\n+$|\0/g, ""); const lines = output.replace(/\n+/g, "\n").replace(/^\n+|\n+$|\0/g, "");
if (output) { for (const line of lines.split("\n").filter(Boolean)) {
console.log(output); console.log(line);
} }
} }
}); });
proc.stderr.on("data", (data) => { proc.stderr.on("data", (data) => {
if (data) { if (data) {
const lines = data.toString().trim(); const output = data.toString().trim();
const output = lines.replace(/\n+/g, "\n").replace(/^\n+|\n+$|\0/g, ""); const lines = output.replace(/\n+/g, "\n").replace(/^\n+|\n+$|\0/g, "");
if (output) { for (const line of lines.split("\n").filter(Boolean)) {
const matches = output.match(/(\d{1,3})%/g); const matches = line.match(/(\d{1,3})%/g);
if (matches) { if (matches) {
const match = Math.max(...matches.map((p) => parseInt(p))); const match = Math.max(...matches.map((p) => parseInt(p)));
const percent = Math.floor(match / 10) * 10; const percent = Math.floor(match / 10) * 10;
+3
View File
@@ -209,6 +209,9 @@ const initApp = () => {
hardware.setDisplayStatus("ON"); hardware.setDisplayStatus("ON");
const args = ["-c", `bash <(wget -qO- ${APP.scripts.install}) update`]; const args = ["-c", `bash <(wget -qO- ${APP.scripts.install}) update`];
hardware.execScriptCommand("bash", args, (progress, error) => { hardware.execScriptCommand("bash", args, (progress, error) => {
if (progress) {
console.log(`Progress: ${progress}%`);
}
updateApp(progress); updateApp(progress);
}); });
} }
+8 -7
View File
@@ -783,13 +783,6 @@ const viewEvents = async () => {
* Register app events and handler. * Register app events and handler.
*/ */
const appEvents = async () => { 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 // Handle multiple instances
app.on("second-instance", () => { app.on("second-instance", () => {
if (WEBVIEW.window.isMinimized()) { if (WEBVIEW.window.isMinimized()) {
@@ -798,6 +791,14 @@ const appEvents = async () => {
WEBVIEW.window.focus(); 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
WEBVIEW.initialized = true; WEBVIEW.initialized = true;