-
-
Notifications
You must be signed in to change notification settings - Fork 52
Expand file tree
/
Copy pathtest-helpers.js
More file actions
29 lines (26 loc) · 782 Bytes
/
test-helpers.js
File metadata and controls
29 lines (26 loc) · 782 Bytes
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
import path from 'path';
import { fileURLToPath } from 'url';
import { validateFolder } from 'check-html-links';
const __dirname = path.dirname(fileURLToPath(import.meta.url));
export async function execute(inPath, opts) {
const testDir = path.join(__dirname, inPath.split('/').join(path.sep));
const errors = await validateFolder(testDir, opts);
return {
cleanup: items => {
const newItems = [];
for (const item of items) {
newItems.push({
...item,
filePath: path.relative(__dirname, item.filePath),
usage: item.usage.map(usageObj => ({
...usageObj,
file: path.relative(__dirname, usageObj.file),
})),
});
}
return newItems;
},
errors,
testDir,
};
}