-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
27 lines (18 loc) · 805 Bytes
/
index.js
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
import { fileExists, argsChecker, loadData, partRunner } from "./utils/helper.js";
const args = process.argv.slice(2);
const { dataType } = await argsChecker(args);
const [year, day] = args;
const dayFile = `day${day}`;
const filePath = `./${year}/${dayFile}/index.js`;
if (!(await fileExists(filePath))) {
console.log(`Day ${args[0]} does not exist`);
process.exit(1);
}
const { part1, part2 } = await import(filePath);
const data = await loadData({ year: year, day: dayFile, dataType });
await partRunner({ part: part1, input: data });
if (dataType === "sample" && (await fileExists(`./${year}/${dayFile}/sample2.txt`))) {
await partRunner({ part: part2, input: await loadData({ day: dayFile, dataType: "sample2" }) });
} else {
await partRunner({ part: part2, input: data });
}