-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathindex.js
68 lines (58 loc) · 1.44 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
const TapRender = require('@munter/tap-render');
const hyperlink = require('hyperlink');
const spot = require('tap-spot');
const globby = require('globby');
const canonicalRoot = process.env.URL;
module.exports = {
onPostBuild: async ({
constants: { PUBLISH_DIR },
inputs: {
entryPoints,
skipPatterns,
todoPatterns,
checkExternal,
pretty,
...defaultInputs
},
utils: {
build: { failBuild },
},
}) => {
/** @type {string} */
const root = PUBLISH_DIR;
/** @type {FilterFunction} */
const skipFilter = (report) =>
Object.values(report).some((value) =>
skipPatterns.some((pattern) => String(value).includes(pattern))
);
/** @type {FilterFunction} */
const todoFilter = (report) =>
Object.values(report).some((value) =>
todoPatterns.some((pattern) => String(value).includes(pattern))
);
const t = new TapRender();
if (pretty) {
t.pipe(spot()).pipe(process.stdout);
} else {
t.pipe(process.stdout);
}
await hyperlink(
{
inputUrls: globby.sync(entryPoints, { cwd: root }),
...defaultInputs,
canonicalRoot,
root,
skipFilter,
todoFilter,
internalOnly: !checkExternal,
pretty: true,
},
t
);
const results = t.close();
if (results.fail) {
return failBuild('Links checking failed');
}
return results;
},
};