The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
Rocket.Chat/apps/meteor/packages/rocketchat-coverage/plugin/compile-version.js

56 lines
1.3 KiB

import { exec } from 'child_process';
import os from 'os';
import util from 'util';
import libReport from 'istanbul-lib-report';
import reports from 'istanbul-reports';
import libCoverage from 'istanbul-lib-coverage';
const dir = process.env.COVERAGE_DIR;
const fileName = process.env.COVERAGE_FILE_NAME;
const reporter = process.env.COVERAGE_REPORTER || 'lcov';
console.log('Coverage plugin started');
if (!dir && !reporter) {
return console.log('Coverage plugin not configured');
}
if (!dir || !reporter) {
console.log('Coverage plugin not fully configured');
return;
}
process.on('exit', async () => {
try {
if (!dir) {
throw new Error('No coverage dir');
}
if (!reporter) {
throw new Error('No coverage reporter');
}
console.log('Coverage plugin triggered');
const coverageMap = libCoverage.createCoverageMap(globalThis['__coverage__']);
const configWatermarks = {
statements: [50, 80],
functions: [50, 80],
branches: [50, 80],
lines: [50, 80],
};
const context = libReport.createContext({
dir,
coverageMap,
});
console.log('Generating coverage report', { dir, reporter, fileName });
const report = reports.create(reporter, { file: fileName });
report.execute(context);
} catch (e) {
console.log('Error', e);
}
});