Skip to content

Commit

Permalink
fix: reduce spammy logs
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-akait committed Dec 7, 2020
1 parent 988d83d commit fb60075
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions packages/webpack-cli/lib/plugins/CLIPlugin.js
Expand Up @@ -42,10 +42,10 @@ class CLIPlugin {

setupHelpfulOutput(compiler) {
const pluginName = 'webpack-cli';
const getCompilationName = (compilation) => (compilation.name ? ` '${compilation.name}'` : '');
const getCompilationName = () => (compiler.name ? ` '${compiler.name}'` : '');

compiler.hooks.run.tap(pluginName, (compiler) => {
this.logger.info(`Compilation${getCompilationName(compiler)} starting...`);
compiler.hooks.run.tap(pluginName, () => {
this.logger.log(`Compilation${getCompilationName()} starting...`);
});

compiler.hooks.watchRun.tap(pluginName, (compiler) => {
Expand All @@ -55,22 +55,22 @@ class CLIPlugin {
this.logger.warn('You are using "bail" with "watch". "bail" will still exit webpack when the first error is found.');
}

this.logger.info(`Compilation${getCompilationName(compiler)} starting...`);
this.logger.log(`Compilation${getCompilationName()} starting...`);
});

compiler.hooks.invalid.tap(pluginName, (filename, changeTime) => {
const date = new Date(changeTime * 1000);

this.logger.info(`File '${filename}' was modified`);
this.logger.log(`File '${filename}' was modified`);
this.logger.log(`Changed time is ${date} (timestamp is ${changeTime})`);
});

(compiler.webpack ? compiler.hooks.afterDone : compiler.hooks.done).tap(pluginName, (stats) => {
this.logger.info(`Compilation${getCompilationName(stats.compilation)} finished`);
(compiler.webpack ? compiler.hooks.afterDone : compiler.hooks.done).tap(pluginName, () => {
this.logger.log(`Compilation${getCompilationName()} finished`);

process.nextTick(() => {
if (compiler.watchMode) {
this.logger.info(`Compiler${getCompilationName(stats.compilation)} is watching files for updates...`);
this.logger.log(`Compiler${getCompilationName()} is watching files for updates...`);
}
});
});
Expand Down

0 comments on commit fb60075

Please sign in to comment.