fix: Include Error properties in logs

This commit is contained in:
Pierre Vanduynslager
2017-10-29 14:37:05 -07:00
committed by Gregor Martynus
parent ad2e1d76b7
commit c90765e10d
5 changed files with 35 additions and 13 deletions
+1 -1
View File
@@ -52,7 +52,7 @@ module.exports = async () => {
logger.log(`%s ${err.message}`, err.code);
} else {
process.exitCode = 1;
logger.error(err);
logger.error('An error occurred while running semantic-release: %O', err);
}
}
};
+8 -3
View File
@@ -6,13 +6,18 @@ const chalk = require('chalk');
module.exports = {
log(...args) {
const [format, ...rest] = args;
console.log(`${chalk.grey('[Semantic release]:')} ${format}`, ...rest.map(arg => chalk.magenta(arg)));
console.log(
`${chalk.grey('[Semantic release]:')}${typeof format === 'string'
? ` ${format.replace(/%[^%]/g, seq => chalk.magenta(seq))}`
: ''}`,
...(typeof format === 'string' ? [] : [format]).concat(rest)
);
},
error(...args) {
const [format, ...rest] = args;
console.error(
`${chalk.grey('[Semantic release]:')} ${chalk.red(format instanceof Error ? format.stack : format)}`,
...rest.map(arg => chalk.red(arg instanceof Error ? arg.stack : arg))
`${chalk.grey('[Semantic release]:')}${typeof format === 'string' ? ` ${chalk.red(format)}` : ''}`,
...(typeof format === 'string' ? [] : [format]).concat(rest)
);
},
};