-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck.js
More file actions
28 lines (23 loc) · 850 Bytes
/
check.js
File metadata and controls
28 lines (23 loc) · 850 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
const fs = require('fs');
const path = require('path');
const coverageDir = './coverage';
const sources = [];
const malformedSources = [];
fs.readdirSync(coverageDir).forEach((fileName) => {
const coverage = JSON.parse(fs.readFileSync(path.resolve(coverageDir, fileName), 'utf8'));
const sourceMapCache = coverage['source-map-cache'];
if (!sourceMapCache) return;
Object.values(sourceMapCache)
.flatMap((cache) => cache.data?.sources || [])
.forEach((source) => {
sources.push(source);
if (/^file:\/\/\/[A-Z]:/.test(source)) return;
malformedSources.push(source);
});
});
console.log(`Found ${sources.length} sources in total:`, sources);
const malformedLength = malformedSources.length;
if (malformedLength > 0) {
console.log(`${malformedLength} malformed:`, malformedSources);
process.exitCode = 1;
}