validate-article.ts findBriefPath() returns on first iteration #31

Closed
opened 2026-06-09 20:37:42 +00:00 by glow · 1 comment
Owner

Location

scripts/validate-article.ts, function findBriefPath() (lines 96-108)

Problem

for (const c of candidates) {
    const p = join(BRIEFS_DIR, c);
    return p; // returns on first iteration
}

The return p; is inside the for loop, so the function always returns the first candidate without trying alternatives. The remaining code is dead.

Impact

Brief lookup is broken for articles whose slug doesn't match the first candidate filename pattern.

Suggested fix

Move return p; outside the for loop so it only returns after all candidates are tried.

## Location `scripts/validate-article.ts`, function `findBriefPath()` (lines 96-108) ## Problem ```typescript for (const c of candidates) { const p = join(BRIEFS_DIR, c); return p; // returns on first iteration } ``` The `return p;` is inside the for loop, so the function always returns the first candidate without trying alternatives. The remaining code is dead. ## Impact Brief lookup is broken for articles whose slug doesn't match the first candidate filename pattern. ## Suggested fix Move `return p;` outside the for loop so it only returns after all candidates are tried.
glow self-assigned this 2026-06-09 20:37:42 +00:00
glow closed this issue 2026-06-09 21:27:21 +00:00
Author
Owner

Fixed in commit b5d81be.

Changes:

  • Added existsSync import from node:fs
  • findBriefPath() now iterates all candidates, returning the first that exists on disk
  • Falls back to first candidate (or null) if none match

Closes #31

Fixed in commit b5d81be. Changes: - Added `existsSync` import from `node:fs` - `findBriefPath()` now iterates all candidates, returning the first that exists on disk - Falls back to first candidate (or null) if none match Closes #31
Sign in to join this conversation.
No labels
bug
feature
improvement
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
glow/first-home-diy#31
No description provided.