From 9c99d4bfc2e9e7dc65028953cdf7df8b71bd6d62 Mon Sep 17 00:00:00 2001 From: Shahar Talmi Date: Mon, 2 Dec 2024 07:24:17 +0200 Subject: [PATCH] fix create bug --- src/utils/renderer.js | 7 ++----- templates/day.template.spec.js | 4 ++-- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/utils/renderer.js b/src/utils/renderer.js index 85668b8a..e4cc6589 100644 --- a/src/utils/renderer.js +++ b/src/utils/renderer.js @@ -83,11 +83,8 @@ export async function downloadIndex(year, bar, stars) { export async function createSolver(year, day) { const page = await getYearPage(year); - if (page.match(new RegExp(`key = "${year}-(\\d+)-"`))) { - const [, actual] = page.match(new RegExp(`key = "${year}-(\\d+)-"`)); - day = actual; - } - if (page.match(/server_eta = (\d+)/)) { + const actual = page.match(new RegExp(`key = "${year}-(\\d+)-"`))?.[1]; + if (actual === day && page.match(/server_eta = (\d+)/)) { const [, eta] = page.match(/server_eta = (\d+)/); const create = await timeoutConfirm({ message: `Create solver ${year}/${dayName(day)}?`, diff --git a/templates/day.template.spec.js b/templates/day.template.spec.js index d8ddc930..ee6d2a40 100644 --- a/templates/day.template.spec.js +++ b/templates/day.template.spec.js @@ -6,7 +6,7 @@ const input = readInput(import.meta.url); describe.only("{{day}} {{year}}", () => { describe("part1", () => { test("it should work for part 1 examples", () => { - expect(part1("1")).toEqual(0); + expect(part1(paste)).toEqual(0); }); test("it should work for part 1 input", () => { @@ -16,7 +16,7 @@ describe.only("{{day}} {{year}}", () => { describe("part2", () => { test("it should work for part 2 examples", () => { - // expect(part2('1')).toEqual(0); + // expect(part2(paste)).toEqual(0); }); test("it should work for part 2 input", () => {