Skip to content
This repository has been archived by the owner on Jul 27, 2021. It is now read-only.

Change the color of dateString #50

Open
flashios09 opened this issue May 23, 2017 · 3 comments
Open

Change the color of dateString #50

flashios09 opened this issue May 23, 2017 · 3 comments

Comments

@flashios09
Copy link

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

@geowarin
Copy link
Owner

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?

@flashios09
Copy link
Author

@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();
    });

@geowarin
Copy link
Owner

Yup I would love that change. 👍
It also relates to #26.

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants