-
Notifications
You must be signed in to change notification settings - Fork 0
/
aoc.ts
41 lines (34 loc) · 873 Bytes
/
aoc.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import { join } from "path";
import { parse } from "flags";
const flags = parse(Deno.args, {
boolean: ["test"],
default: { test: false },
"--": true,
});
const date = new Date();
const currentDay = date.getDate().toString();
const currentYear = date.getFullYear().toString();
const [year = currentYear, day = currentDay] = Deno.args;
const command = new Deno.Command(Deno.execPath(), {
args: [
flags.test ? `test` : `run`,
"-A",
join(
year,
day.padStart(2, "0"),
flags.test ? "solution.test.ts" : "solution.ts"
),
],
});
console.log([
flags.test ? `test` : `run`,
"-A",
join(
year,
day.padStart(2, "0"),
flags.test ? "solution.test.ts" : "solution.ts"
),
]);
const { stdout, stderr } = command.outputSync();
console.log(new TextDecoder().decode(stdout));
console.log(new TextDecoder().decode(stderr));