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.
*/
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;
+3
View File
@@ -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);
});
}
+8 -7
View File
@@ -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;