Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -986,7 +986,7 @@
},
{
"source": "/v3/documentation/smart-contracts/fift/overview",
"destination": "/languages/fift",
"destination": "/languages/fift/overview",
"permanent": true
},
{
Expand Down
16 changes: 10 additions & 6 deletions scripts/check-redirects.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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)));
Expand All @@ -83,7 +83,7 @@ const checkUnique = (config) => {
navOverrides,
'Redirect sources in docs.json must not replace existing paths!',
),
}
};
}
// Otherwise
return { ok: true };
Expand Down Expand Up @@ -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!'));
Expand Down Expand Up @@ -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...');
Expand Down