UNPKG

1.01 kBJavaScriptView Raw
1import path from 'path';
2import { commonTokens, tokens } from '@stryker-mutator/api/plugin';
3import fileUrl from 'file-url';
4import { reporterUtil } from './reporter-util.js';
5const INDENTION_LEVEL = 0;
6export const RESOURCES_DIR_NAME = 'strykerResources';
7export 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}
25JsonReporter.inject = tokens(commonTokens.options, commonTokens.logger);
26//# sourceMappingURL=json-reporter.js.map
\No newline at end of file