Mailspring/spec/n1-spec-runner/console-reporter.es6
Halla Moore 6f571a323f fix(decaffeination) Remove second arg from some slice calls
Decaffination replaces someString[index..-1] with
someString.slice(index, -1 + 1), which is bizzare. This commit changes those
instances to someString.slice(index).
2016-11-02 12:40:01 -07:00

31 lines
818 B
JavaScript

const originalLog = console.log;
const originalWarn = console.warn;
const originalError = console.error;
export default class ConsoleReporter {
reportSpecStarting(spec) {
const withContext = (log) => {
return (...args) => {
if (args[0] === '.') {
return log(...args);
}
return log(`[${spec.getFullName()}] ${args[0]}`, ...args.slice(1));
}
}
console.log = withContext(originalLog);
console.warn = withContext(originalWarn);
console.error = withContext(originalError);
}
reportSpecResults() {
if (console.log !== originalLog) {
console.log = originalLog;
}
if (console.warn !== originalWarn) {
console.warn = originalWarn;
}
if (console.error !== originalError) {
console.error = originalError;
}
}
}