From e49ee93abc4779865b1f3b5dbbf506ddb7b2f261 Mon Sep 17 00:00:00 2001 From: Novus Nota <68142933+novusnota@users.noreply.github.com> Date: Fri, 7 Nov 2025 12:55:59 +0100 Subject: [PATCH] fix(ci): confirm file existence in redirect checks --- docs.json | 2 +- scripts/check-redirects.mjs | 16 ++++++++++------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/docs.json b/docs.json index 873f41b7c..ec31ec4dd 100644 --- a/docs.json +++ b/docs.json @@ -986,7 +986,7 @@ }, { "source": "/v3/documentation/smart-contracts/fift/overview", - "destination": "/languages/fift", + "destination": "/languages/fift/overview", "permanent": true }, { diff --git a/scripts/check-redirects.mjs b/scripts/check-redirects.mjs index a93e3cdb6..5fda787d1 100644 --- a/scripts/check-redirects.mjs +++ b/scripts/check-redirects.mjs @@ -14,7 +14,7 @@ ╚─────────────────────────────────────────────────────────────────────────────*/ // Node.js -import { existsSync, mkdtempSync, rmSync, readFileSync } from 'node:fs'; +import { existsSync, statSync, mkdtempSync, rmSync, readFileSync } from 'node:fs'; import { join } from 'node:path'; import { tmpdir } from 'node:os'; import { spawnSync } from 'node:child_process'; @@ -71,7 +71,7 @@ const checkUnique = (config) => { loops, 'Redirect sources in docs.json must not self-reference in destinations!', ), - } + }; } const navLinks = getNavLinksSet(config); const navOverrides = redirectSources.filter((it) => navLinks.has(fmt(it))); @@ -83,7 +83,7 @@ const checkUnique = (config) => { navOverrides, 'Redirect sources in docs.json must not replace existing paths!', ), - } + }; } // Otherwise return { ok: true }; @@ -111,7 +111,11 @@ const checkExist = (config) => { return false; } const rel = it.replace(/^\/+/, '').replace(/#.*$/, '').replace(/\?.*$/, ''); - return [rel === '' ? `index.mdx` : `${rel}/index.mdx`, `${rel}.mdx`, `${rel}`].some(existsSync) === false; + return ( + [rel === '' ? `index.mdx` : `${rel}/index.mdx`, `${rel}.mdx`, `${rel}`].some( + (path) => existsSync(path) && statSync(path).isFile(), + ) === false + ); }); if (repoIssuesDestsExist) { console.log(composeWarning('Found GitHub issue destinations!')); @@ -304,11 +308,11 @@ const main = async () => { console.log(res.error); } else { console.log(composeSuccess(rawSuccessMsg)); - }; + } if (shouldRunAll) { console.log(); // intentional break } - } + }; if (shouldRunAll || argUnique) { console.log('🏁 Checking the uniqueness of redirect sources in docs.json...');