From bd12d308d0391c4e43f33dda7acee524676e4695 Mon Sep 17 00:00:00 2001 From: Nulo Date: Thu, 9 Feb 2023 21:38:00 -0300 Subject: [PATCH] permitir logear cosas de debug --- alpine.ts | 20 ++++++++++++-------- helpers/logger.ts | 3 +++ 2 files changed, 15 insertions(+), 8 deletions(-) create mode 100644 helpers/logger.ts diff --git a/alpine.ts b/alpine.ts index 9d1c1a2..02b7836 100644 --- a/alpine.ts +++ b/alpine.ts @@ -12,6 +12,7 @@ import { Fstab } from "./fstab.js"; import { execFile } from "./helpers/better-api.js"; import { PasswdEntry, sudoReadPasswd } from "./helpers/passwd.js"; import { sudoWriteExecutable } from "./helpers/sudo.js"; +import { logDebug } from "./helpers/logger.js"; export class Alpine { dir: string; @@ -76,14 +77,17 @@ export class Alpine { } async addPackages(packages: string[]): Promise { - await execFile("sudo", [ - "apk", - "add", - "--clean-protected", - "--root", - this.dir, - ...packages, - ]); + logDebug( + "addPackages", + await execFile("sudo", [ + "apk", + "add", + "--clean-protected", + "--root", + this.dir, + ...packages, + ]) + ); } static async makeWorld({ diff --git a/helpers/logger.ts b/helpers/logger.ts new file mode 100644 index 0000000..66d0dea --- /dev/null +++ b/helpers/logger.ts @@ -0,0 +1,3 @@ +export function logDebug(scope: string, message: any) { + if (process.argv.includes("-v")) console.debug(`[${scope}]`, message); +}