UNPKG

@eris/image-cli

Version:

CLI wrapper and standalone executable API for @eris/image.

49 lines 1.76 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); class JsonReporter { constructor() { this._startTime = 0; this._entryStartTimes = new Map(); } _log(obj) { console.log(JSON.stringify(obj)); // tslint:disable-line no-console } started() { this._startTime = Date.now(); this._log({ type: 'started', data: {} }); } finished(err) { const errPayload = err && { message: err.message, stack: err.stack }; const timeTaken = Date.now() - this._startTime; this._log({ type: 'finished', data: { timeTaken }, error: errPayload }); } entryStarted(config) { this._entryStartTimes.set(config.id, Date.now()); const id = config.id; const input = config.input; const data = { id, input }; this._log({ type: 'entryStarted', data }); } entryFinished(config, result) { const id = config.id; const input = config.input; const output = config.output; const timeTaken = Date.now() - (this._entryStartTimes.get(id) || 0); const data = { id, input, output, timeTaken, result }; if (!config.toReporter) { delete data.result; } this._log({ type: 'entryFinished', data }); } entryErrored(config, err) { const id = config.id; const input = config.input; const timeTaken = Date.now() - (this._entryStartTimes.get(id) || 0); const message = err.message; const stack = err.stack; const data = { id, input, timeTaken, error: { message, stack } }; this._log({ type: 'entryErrored', data }); } } exports.JsonReporter = JsonReporter; //# sourceMappingURL=json-reporter.js.map