feat: add logs about prepare, publish, success and fail plugins skipped in dry-run mode

This commit is contained in:
Pierre Vanduynslager
2018-11-14 11:27:06 -05:00
parent 90b497464e
commit 90da6a0bc1
6 changed files with 73 additions and 52 deletions
+15 -12
View File
@@ -27,20 +27,23 @@ module.exports = (context, type, pluginOpt, pluginsPath) => {
}
const validator = async input => {
const {outputValidator} = PLUGINS_DEFINITIONS[type] || {};
const {dryRun, outputValidator} = PLUGINS_DEFINITIONS[type] || {};
try {
logger.log(`Start step "${type}" of plugin "${pluginName}"`);
const result = await func({
...cloneDeep(omit(input, ['stdout', 'stderr', 'logger'])),
stdout,
stderr,
logger: logger.scope(logger.scopeName, pluginName),
});
if (outputValidator && !outputValidator(result)) {
throw getError(`E${type.toUpperCase()}OUTPUT`, {result, pluginName});
if (!input.options.dryRun || dryRun) {
logger.log(`Start step "${type}" of plugin "${pluginName}"`);
const result = await func({
...cloneDeep(omit(input, ['stdout', 'stderr', 'logger'])),
stdout,
stderr,
logger: logger.scope(logger.scopeName, pluginName),
});
if (outputValidator && !outputValidator(result)) {
throw getError(`E${type.toUpperCase()}OUTPUT`, {result, pluginName});
}
logger.success(`Completed step "${type}" of plugin "${pluginName}"`);
return result;
}
logger.success(`Completed step "${type}" of plugin "${pluginName}"`);
return result;
logger.warn(`Skip step "${type}" of plugin "${pluginName}" in dry-run mode`);
} catch (error) {
logger.error(`Failed step "${type}" of plugin "${pluginName}"`);
extractErrors(error).forEach(err => Object.assign(err, {pluginName}));