-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathrunner.ts
More file actions
34 lines (31 loc) · 1013 Bytes
/
Copy pathrunner.ts
File metadata and controls
34 lines (31 loc) · 1013 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
30
31
32
33
34
import type { RunnerFunction } from '@code-pushup/models';
import { executeProcess } from '@code-pushup/utils';
import type { FinalCoveragePluginConfig } from '../config.js';
import { lcovResultsToAuditOutputs } from './lcov/lcov-runner.js';
export function createRunnerFunction(
config: FinalCoveragePluginConfig,
): RunnerFunction {
return async () => {
const {
reports,
coverageToolCommand,
continueOnCommandFail,
coverageTypes,
} = config;
// Run coverage tool if provided
if (coverageToolCommand != null) {
const { command, args } = coverageToolCommand;
try {
await executeProcess({ command, args });
} catch {
if (!continueOnCommandFail) {
throw new Error(
'Coverage plugin: Running coverage tool failed. Make sure all your provided tests are passing.',
);
}
}
}
// Calculate coverage from LCOV results
return lcovResultsToAuditOutputs(reports, coverageTypes);
};
}