Skip to content

Commit 1b86ed9

Browse files
committed
print
1 parent 00886ca commit 1b86ed9

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

backup.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ function borg(...args: string[]): Promise<Deno.CommandOutput> {
88
return new Deno.Command("borg", { args }).output();
99
}
1010

11+
function print(encoded: Uint8Array): void {
12+
console.log(new TextDecoder().decode(encoded));
13+
}
14+
1115
const command = new Command()
1216
.name("backup")
1317
.option("-v --verbose", "Enable verbose logging")
@@ -45,9 +49,11 @@ const command = new Command()
4549
const resp = await borg("init", "-e=none", repo);
4650
if (!resp.success) {
4751
console.log("failed to init repo");
48-
if (verbose) console.log(new TextDecoder().decode(resp.stderr));
52+
if (verbose) print(resp.stderr);
4953
Deno.exit(1);
5054
}
55+
56+
if (verbose) print(resp.stderr);
5157
}
5258

5359
const bytes = new Uint8Array(6);
@@ -63,11 +69,11 @@ const command = new Command()
6369

6470
if (!resp.success) {
6571
console.log("failed to create backup");
66-
if (verbose) console.log(new TextDecoder().decode(resp.stderr));
72+
if (verbose) print(resp.stderr);
6773
Deno.exit(1);
6874
}
6975

70-
if (verbose) console.log(new TextDecoder().decode(resp.stderr));
76+
if (verbose) print(resp.stderr);
7177

7278
// TODO: Automatic rclone
7379
});

0 commit comments

Comments
 (0)