Skip to content

Commit

Permalink
feat: windows visual improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
Pooya Parsa committed Apr 4, 2018
1 parent f6a9cba commit 2ae8339
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export default class WebpackBarPlugin extends webpack.ProgressPlugin {
this.handler = (percent, msg, ...details) =>
this.updateProgress(percent, msg, details);

this._render = _.throttle(this.render, 25);
this._render = _.throttle(this.render, 100);

this.logUpdate =
this.options.logUpdate ||
Expand Down
17 changes: 5 additions & 12 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,8 @@ import prettyTime from 'pretty-time';
import getDescription from './description';

const BAR_LENGTH = 25;
const IS_WINDOWS = /^win/.test(process.platform);
const BLOCK_CHAR = IS_WINDOWS ? ' ' : '█';
const BLOCK_CHAR2 = IS_WINDOWS ? '=' : '█';
const BAR_BEFORE = IS_WINDOWS ? '[' : '';
const BAR_AFTER = IS_WINDOWS ? ']' : '';
const BLOCK_CHAR = '█';
const BLOCK_CHAR2 = '█';
const NEXT = chalk.blue(figures(' › '));

export const BULLET = figures('●');
Expand All @@ -30,13 +27,9 @@ export const renderBar = (progress, color) => {
const bg = chalk.white(BLOCK_CHAR);
const fg = colorize(color)(BLOCK_CHAR2);

return (
BAR_BEFORE +
_.range(BAR_LENGTH)
.map((i) => (i < w ? fg : bg))
.join('') +
BAR_AFTER
);
return _.range(BAR_LENGTH)
.map((i) => (i < w ? fg : bg))
.join('');
};

const hasValue = (s) => s && s.length;
Expand Down

0 comments on commit 2ae8339

Please sign in to comment.