forked from FuelLabs/fuels-ts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtests-coverage-merge.ts
36 lines (31 loc) · 1.23 KB
/
tests-coverage-merge.ts
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
import { execSync } from 'child_process';
import { readdirSync, renameSync, rmSync } from 'fs';
import { join } from 'path';
const restructureCoverageDirectory = () => {
const coverageDir = join(__dirname, '../coverage/');
const environmentsDir = join(coverageDir, '/environments/');
const validEnvironments = ['node', 'browser'];
const environments = readdirSync(environmentsDir);
environments.forEach((environment) => {
if (validEnvironments.includes(environment)) {
// Move environment coverage directories to a single file
renameSync(
join(environmentsDir, `${environment}/coverage-final.json`),
join(environmentsDir, `${environment}.json`)
);
// Remove environment coverage directory
rmSync(join(environmentsDir, environment), { recursive: true, force: true });
}
});
};
(() => {
// Structure all coverage environment dirs into a single dir
restructureCoverageDirectory();
// Merge all coverage files
execSync('nyc merge coverage/environments coverage/merged/coverage.json', { stdio: 'inherit' });
// Generate coverage report
execSync(
'nyc report --temp-dir=coverage/merged --report-dir=coverage/report --exclude-after-remap=false',
{ stdio: 'inherit' }
);
})();