mirror of
https://github.com/seigler/advent-of-code-2020
synced 2025-07-25 23:36:10 +00:00
28 lines
612 B
JavaScript
28 lines
612 B
JavaScript
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()
|