make sure to display errors and tasks that are skipped by catching it

This commit is contained in:
Ken 2019-01-05 12:45:34 -08:00
Родитель ed8816e3b5
Коммит 2ebdffd6c9
2 изменённых файлов: 16 добавлений и 10 удалений

Просмотреть файл

@ -61,16 +61,28 @@ undertaker.on('error', function(args: any) {
logger.error(chalk.yellow('------------------------------------'));
process.exitCode = 1;
} else if (shouldLog(args)) {
const duration = args.duration;
const durationInSecs = Math.round(((duration[0] * NS_PER_SEC + duration[1]) / NS_PER_SEC) * 100) / 100;
logger.error(`finished '${colorizeTaskName(args.name)}' in ${chalk.yellow(String(durationInSecs) + 's')} with ${chalk.red('errors')}`);
process.exitCode = 1;
}
if (topLevelTask === args.name) {
process.exit(1);
}
});
process.on('exit', code => {
if (code !== 0) {
logger.error(chalk.dim(`Error previously detected. See above for error messages.`));
}
if (topLevelTask === args.name && Object.keys(tasksInProgress).length > 0) {
if (Object.keys(tasksInProgress).length > 0) {
logger.error(
`Other tasks that did not complete: [${Object.keys(tasksInProgress)
.map(taskName => colorizeTaskName(taskName))
.join(', ')}]`
);
process.exit(1);
}
});

Просмотреть файл

@ -8,19 +8,13 @@ export function wrapTask(fn: any) {
if (origFn.length > 0) {
(fn as any).call(null, done);
} else {
let results = (fn as any).call();
let results = (origFn as any).call();
// The result is a function, we will assume that this is a task function to be called
if (results && typeof results === 'function') {
return results.call(null, done);
} else if (results && results.then) {
return results
.then(() => {
done();
})
.catch((e: any) => {
done(e);
});
return results;
}
done();