1 | import path from 'path';
|
2 | import { commonTokens, tokens } from '@stryker-mutator/api/plugin';
|
3 | import fileUrl from 'file-url';
|
4 | import { reporterUtil } from './reporter-util.js';
|
5 | const INDENTION_LEVEL = 0;
|
6 | export const RESOURCES_DIR_NAME = 'strykerResources';
|
7 | export class JsonReporter {
|
8 | constructor(options, log) {
|
9 | this.options = options;
|
10 | this.log = log;
|
11 | }
|
12 | onMutationTestReportReady(report) {
|
13 | this.mainPromise = this.generateReport(report);
|
14 | }
|
15 | wrapUp() {
|
16 | return this.mainPromise;
|
17 | }
|
18 | async generateReport(report) {
|
19 | const filePath = path.normalize(this.options.jsonReporter.fileName);
|
20 | this.log.debug(`Using relative path ${filePath}`);
|
21 | await reporterUtil.writeFile(path.resolve(filePath), JSON.stringify(report, null, INDENTION_LEVEL));
|
22 | this.log.info(`Your report can be found at: ${fileUrl(filePath)}`);
|
23 | }
|
24 | }
|
25 | JsonReporter.inject = tokens(commonTokens.options, commonTokens.logger);
|
26 |
|
\ | No newline at end of file |