UNPKG

@quenty/cli-output-helpers

Version:

Helpers to generate Nevermore package and game templates

43 lines 1.46 kB
import { OutputHelper } from '../outputHelper.js'; import { BaseReporter } from './reporter.js'; import { formatProgressResult } from './progress-format.js'; /** * Reporter for single-package execution. * Prints logs and pass/fail inline, reads failure state from the tracker. */ export class SimpleReporter extends BaseReporter { _state; _alwaysShowLogs; _successMessage; _failureMessage; constructor(state, options) { super(); this._state = state; this._alwaysShowLogs = options.alwaysShowLogs; this._successMessage = options.successMessage ?? 'Completed!'; this._failureMessage = options.failureMessage ?? 'Failed!'; } onPackageResult(result) { const showLogs = this._alwaysShowLogs || !result.success; if (result.logs && showLogs) { console.log(result.logs); } else if (showLogs) { OutputHelper.info('(no output)'); } const progressText = formatProgressResult(result.progressSummary); if (result.success) { const msg = progressText ? `${this._successMessage} ${progressText}` : this._successMessage; OutputHelper.info(msg); } else { OutputHelper.error(this._failureMessage); } } async stopAsync() { if (this._state.getFailures().length > 0) { process.exit(1); } } } //# sourceMappingURL=simple-reporter.js.map