Skip to content
This repository has been archived by the owner on Jan 8, 2025. It is now read-only.

Commit

Permalink
Catch bad sources
Browse files Browse the repository at this point in the history
  • Loading branch information
ptgott committed Oct 10, 2024
1 parent 81708e4 commit fb59889
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
14 changes: 14 additions & 0 deletions server/config-docs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,20 @@ export const loadConfig = (version: string) => {
);
}

const redirsFrom = checkForRedirectsFromExistingFiles(
join("content", version, "docs", "pages"),
config.redirects
);

if (redirsFrom.length > 0) {
throw new Error(
"Error parsing docs config file " +
join("content", version, "docs", "config.json") +
': Each of the following redirects includes a "source" that corresponds to an existing file: ' +
JSON.stringify(redirsFrom, null, 2)
);
}

const duplicateRedirects = checkDuplicateRedirects(config.redirects);
if (duplicateRedirects.length > 0) {
throw new Error(
Expand Down
3 changes: 0 additions & 3 deletions uvu-tests/config-docs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,4 @@ Suite("Checks for redirects from existing paths", () => {
assert.equal(actual, expected);
});

// TODO: Test for from files that exist (maybe do this in
// CheckForCorresponding?)

Suite.run();

0 comments on commit fb59889

Please sign in to comment.