scripts/verify-links: skip api reference link validation locally

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2023-11-14 17:59:02 +01:00
parent d9a16db9d2
commit 8f3104b845
+12
View File
@@ -168,6 +168,9 @@ async function findExternalDocsLinks(dir) {
async function main() {
process.chdir(projectRoot);
const isCI = Boolean(process.env.CI);
const hasReference = existsSync(resolvePath(projectRoot, 'docs/reference'));
const files = await listFiles('.');
const mdFiles = files.filter(f => f.endsWith('.md'));
const badUrls = [];
@@ -180,10 +183,19 @@ async function main() {
badUrls.push(...badFileUrls);
}
if (!hasReference) {
console.log(
"Skipping API reference link validation, no docs/reference/ dir. Reference docs can be built with 'yarn build:api-docs'",
);
}
if (badUrls.length) {
console.log(`Found ${badUrls.length} bad links within repo`);
for (const { url, basePath, problem } of badUrls) {
if (problem === 'missing') {
if (url.startsWith('../reference/') && !isCI && !hasReference) {
continue;
}
console.error(
`Unable to reach ${url} from root or microsite/static/, linked from ${basePath}`,
);