Skip to content

Commit 0559ed6

Browse files
committed
[ci skip] fix: only check Javadoc links in CI
1 parent 9a08270 commit 0559ed6

1 file changed

Lines changed: 12 additions & 7 deletions

File tree

src/utils/remark/javadoc.ts

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import type { RemarkPlugin } from "@astrojs/markdown-remark";
22
import { deadOrAlive } from "dead-or-alive";
33
import { visit } from "unist-util-visit";
44

5+
const CI = Boolean(process.env.CI);
6+
57
// replaces special Markdown links with Javadoc URLs
68
// link format: jd:<javadoc name>[:<module name>][:<fully qualified class name; . as package separator, $ for inner>]
79

@@ -58,13 +60,16 @@ const parse = async (url: string, { targets }: Options): Promise<string | null>
5860
const module = match[3] ? match[2] : typeof target !== "string" ? target.module : undefined;
5961
const parsed = `${targetUrl}/${module ? `${module}/` : ""}${asUrl(name)}`;
6062

61-
const result = await deadOrAlive(parsed, {
62-
findUrls: false,
63-
followMetaHttpEquiv: false,
64-
userAgent: "PaperMC/docs (https://docs.papermc.io)",
65-
});
66-
if (result.status !== "alive") {
67-
error(new Error(`Received dead status for Javadoc link "${url}"`));
63+
if (CI) {
64+
// only check links in CI to avoid rate limiting during local development
65+
const result = await deadOrAlive(parsed, {
66+
findUrls: false,
67+
followMetaHttpEquiv: false,
68+
userAgent: "PaperMC/docs (https://docs.papermc.io)",
69+
});
70+
if (result.status !== "alive") {
71+
error(new Error(`Received dead status for Javadoc link "${url}"`));
72+
}
6873
}
6974

7075
return parsed;

0 commit comments

Comments
 (0)