permitir logear cosas de debug

This commit is contained in:
Cat /dev/Nulo 2023-02-09 21:38:00 -03:00
parent 92c82d5ad8
commit bd12d308d0
2 changed files with 15 additions and 8 deletions

View file

@ -12,6 +12,7 @@ import { Fstab } from "./fstab.js";
import { execFile } from "./helpers/better-api.js"; import { execFile } from "./helpers/better-api.js";
import { PasswdEntry, sudoReadPasswd } from "./helpers/passwd.js"; import { PasswdEntry, sudoReadPasswd } from "./helpers/passwd.js";
import { sudoWriteExecutable } from "./helpers/sudo.js"; import { sudoWriteExecutable } from "./helpers/sudo.js";
import { logDebug } from "./helpers/logger.js";
export class Alpine { export class Alpine {
dir: string; dir: string;
@ -76,14 +77,17 @@ export class Alpine {
} }
async addPackages(packages: string[]): Promise<void> { async addPackages(packages: string[]): Promise<void> {
await execFile("sudo", [ logDebug(
"apk", "addPackages",
"add", await execFile("sudo", [
"--clean-protected", "apk",
"--root", "add",
this.dir, "--clean-protected",
...packages, "--root",
]); this.dir,
...packages,
])
);
} }
static async makeWorld({ static async makeWorld({

3
helpers/logger.ts Normal file
View file

@ -0,0 +1,3 @@
export function logDebug(scope: string, message: any) {
if (process.argv.includes("-v")) console.debug(`[${scope}]`, message);
}