plugins: Improve logging of plugin events

This will make it easier to troubleshoot plugin and npm issues.
This commit is contained in:
Richard Hansen 2021-02-10 01:34:38 -05:00 committed by John McLear
parent 4253a2ea8f
commit dcf7891316
3 changed files with 24 additions and 14 deletions

View file

@ -21,13 +21,8 @@ const stderrLogger = (line) => npmLogger.error(line);
*/
module.exports = exports = (args, opts = {}) => {
const cmd = ['npm', ...args];
logger.info(`Executing command: ${cmd.join(' ')}`);
const p = runCmd(cmd, {stdoutLogger, stderrLogger, ...opts});
p.then(
() => logger.info(`Successfully ran command: ${cmd.join(' ')}`),
() => logger.error(`npm command failed: ${cmd.join(' ')}`));
// MUST return the original Promise returned from runCmd so that the caller can access stdout.
return p;
return runCmd(cmd, {stdoutLogger, stderrLogger, ...opts});
};
// Log the version of npm at startup.