Skip to content

Commit 65be8e0

Browse files
committed
add some prompts
1 parent 9f3e2b6 commit 65be8e0

1 file changed

Lines changed: 15 additions & 3 deletions

File tree

script/check-internal-links.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,31 @@
33
const linkinator = require('linkinator')
44
const checker = new linkinator.LinkChecker()
55
const { deprecated } = require('../lib/enterprise-server-releases')
6+
const englishRoot = 'http://localhost:4002/en'
67

78
// [start-readme]
89
//
910
// This script runs in CI via GitHub Action to check all *internal* links in English content,
1011
// not including deprecated Enterprise Server content. This is different from script/check-english-links.js,
1112
// which checks *all* links in the site, both internal and external, and is much slower.
1213
//
14+
// If you want to run it locally, you must have a local server running. You can use `npm run link-check`.
15+
//
1316
// [end-readme]
1417

1518
const config = {
16-
path: 'http://localhost:4002/en',
19+
path: englishRoot,
1720
// Use concurrency = 10 to optimize for Actions
1821
// See https://github.com/JustinBeckwith/linkinator/issues/135#issuecomment-623240879
1922
concurrency: 10,
2023
recurse: true,
2124
linksToSkip: [
22-
// Skip any link that is not an internal link
23-
'^((?!http://localhost:4002/en).)*$',
25+
// Skip any link that is not an internal link.
26+
// NOTE: If we want this test to check for broken asset paths in the future,
27+
// we can remove `en` from the path below. This will increase the runtime, but that
28+
// may be an acceptable tradeoff. For the record: `check-external-links`, which runs
29+
// nightly, currently does check for broken asset paths.
30+
`^((?!${englishRoot}).)*$`,
2431
// Skip dist files
2532
'/dist/index.*',
2633
// Skip deprecated Enterprise content
@@ -37,6 +44,11 @@ async function main () {
3744
.filter(link => link.state === 'BROKEN')
3845
.map(link => { delete link.failureDetails; return link })
3946

47+
if (brokenLinks.length === 1 && brokenLinks[0].url === englishRoot) {
48+
console.log(`You must be running ${englishRoot}!\n\nTry instead: npm run link-check`)
49+
process.exit(1)
50+
}
51+
4052
// Exit successfully if no broken links!
4153
if (!brokenLinks.length) {
4254
console.log('All links are good!')

0 commit comments

Comments
 (0)