friendly-errors-webpack-plugin icon indicating copy to clipboard operation
friendly-errors-webpack-plugin copied to clipboard

Change the color of dateString

Open flashios09 opened this issue 8 years ago • 3 comments

Hi,

On my terminal(iTerm2 MacOS), i'm using a gray bg and the dateString is displayed in black

Is it possible to change the dateString color to blue/white/gray or add an option to choose it ? Something like this:

new FriendlyErrorsPlugin({
    output: {
        dateString: {color: 'blue'}
    }
});

On node_modules/friendly-errors-webpack-plugin/src/output.js:54, i found this:

// Line 54:
const dateString = chalk.grey(date.toLocaleTimeString());

On github chalk depo documentation, there is no grey color ! I tried chalk.gray(date.toLocaleTimeString()) -> doesn't work !

So i change it to chalk.blue(date.toLocaleTimeString()) -> it works

Thanks

flashios09 avatar May 23 '17 01:05 flashios09

Hi @flashios09,

Grey seems to work fine on my color scheme, do you think we should change it?

Providing options to override the default colors seems like a reasonable solution if we can't find a good color scheme that works for everyone.

What do you think?

geowarin avatar May 24 '17 11:05 geowarin

@geowarin unfortunately the grey doesn't work for me :( I'm for adding an option to specify the dateString color and i will try to create a PR tonight.

I have another point to discuss, i always need to know when the last time i compiled(i mean the last save) and took time, if we have many eslint warnings, we have to scroll up to see the dateString and we don't have the took info, what about adding it at the end of the output. Something like this:

    compiler.plugin('done', stats => {
      this.clearConsole();

      const hasErrors = stats.hasErrors();
      const hasWarnings = stats.hasWarnings();
      const date = new Date();
      const lastCompile = chalk.magenta(date.toLocaleDateString()) + " at " + chalk.blue(date.toLocaleTimeString());
      const time = getCompileTime(stats) / 1000;
      const took = (time < 5) ? chalk.green(time + "s") : chalk.red(time + "s");


      if (!hasErrors && !hasWarnings) {
        this.displaySuccess(stats);
        return;
      }

      if (hasErrors) {
        this.displayErrors(extractErrorsFromStats(stats, 'errors'), 'error');
        return;
      }

      if (hasWarnings) {
        this.displayErrors(extractErrorsFromStats(stats, 'warnings'), 'warning');
      }

      output.log();
      output.log("Last compile: " + lastCompile);
      output.log("Took: " + took);
      output.log();
    });

flashios09 avatar May 24 '17 11:05 flashios09

Yup I would love that change. :+1: It also relates to #26.

If you could have a go a it that would be wonderful!

geowarin avatar May 24 '17 11:05 geowarin