mirror of
https://github.com/seigler/advent-of-code-2020
synced 2025-07-27 00:06:09 +00:00
Initial commit
This commit is contained in:
commit
f3d555f01c
12 changed files with 370 additions and 0 deletions
28
run.js
Normal file
28
run.js
Normal file
|
@ -0,0 +1,28 @@
|
|||
const solutionId = process.argv[2]
|
||||
|
||||
async function start () {
|
||||
try {
|
||||
await runSolution()
|
||||
} catch (ex) {
|
||||
if (!solutionId) {
|
||||
console.error('No solution ID provided; please re-run with an argument, e.g.: npm start day1, or: node run day1')
|
||||
} else {
|
||||
await copyTemplate()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function runSolution () {
|
||||
return require(`./solutions/${solutionId}/solution.js`)
|
||||
}
|
||||
|
||||
async function copyTemplate () {
|
||||
try {
|
||||
await require('./copy-template.js')
|
||||
await runSolution()
|
||||
} catch (ex) {
|
||||
console.error(`Unable to run solution for '${solutionId}': ${ex}`, ex.stack)
|
||||
}
|
||||
}
|
||||
|
||||
start()
|
Loading…
Add table
Add a link
Reference in a new issue