Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function intercept({ send }) {
const ocm = ['log', 'info', 'warn', 'error'];
const oc = {};
ocm.forEach(function each(method) {
oc[method] = console[method];
console[method] = send.bind(send, `console.${method}`);
});
return once(async function after() {
ocm.forEach(function each(method) {
console[method] = oc[method];
delete oc[method];
});
});
}
complete() {
return once(async function completed(err) {
debug('completed the run', err);
if (err) {
if (typeof err === 'number') {
err = new Error(`Test are failing with exit code ${err}`);
}
this.subway.send('complete', failure(err));
} else {
this.subway.send('complete');
}
await this.teardown();
}.bind(this));
}