UNPKG

@quenty/cli-output-helpers

Version:

Helpers to generate Nevermore package and game templates

33 lines 1.14 kB
import * as fs from 'fs/promises'; import { OutputHelper } from '../outputHelper.js'; import { BaseReporter } from './reporter.js'; /** * Writes a JSON results file when jobs complete. * Output matches the BatchSummary shape for backward compatibility. */ export class JsonFileReporter extends BaseReporter { _state; _outputPath; constructor(state, outputPath) { super(); this._state = state; this._outputPath = outputPath; } async stopAsync() { const results = this._state.getResults(); const failures = this._state.getFailures(); const durationMs = Date.now() - this._state.startTimeMs; const summary = { packages: results, summary: { total: results.length, passed: results.length - failures.length, failed: failures.length, durationMs, }, }; await fs.writeFile(this._outputPath, JSON.stringify(summary, null, 2)); OutputHelper.info(`Results written to ${this._outputPath}`); } } //# sourceMappingURL=json-file-reporter.js.map