mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-30 09:27:13 +00:00
feat: better windows support for progressbar
This commit is contained in:
parent
417e0bff40
commit
c2d6740f0c
@ -5,8 +5,13 @@ import logUpdate from 'log-update'
|
||||
|
||||
const sharedState = {}
|
||||
|
||||
const BLOCK_CHAR = '█'
|
||||
const BAR_LENGTH = 25
|
||||
const IS_WINDOWS = false
|
||||
const BLOCK_CHAR = IS_WINDOWS ? ' ' : '█'
|
||||
const BLOCK_CHAR2 = IS_WINDOWS ? '#' : '█'
|
||||
const ICON_CHAR = IS_WINDOWS ? ':' : '⠸'
|
||||
const BAR_BEFORE = IS_WINDOWS ? chalk.grey('[') : ''
|
||||
const BAR_AFTER = IS_WINDOWS ? chalk.grey(']') : ''
|
||||
|
||||
export default class ProgressPlugin extends webpack.ProgressPlugin {
|
||||
constructor(options) {
|
||||
@ -55,7 +60,7 @@ export default class ProgressPlugin extends webpack.ProgressPlugin {
|
||||
|
||||
const _color = chalk.keyword(state.color)
|
||||
|
||||
const _icon = _color('⠸')
|
||||
const _icon = _color(ICON_CHAR)
|
||||
const _name = _color(_.startCase(name))
|
||||
const _bar = this._renderBar(state.progress, state.color)
|
||||
const _msg = chalk.grey(_.startCase(state.msg))
|
||||
@ -76,9 +81,9 @@ export default class ProgressPlugin extends webpack.ProgressPlugin {
|
||||
const bg = chalk.white(BLOCK_CHAR)
|
||||
// const fg = chalk.keyword(color)(BLOCK_CHAR)
|
||||
|
||||
const base = color === 'green' ? 100 : 50
|
||||
const fg = i => chalk.hsl(i * 3 + base, 100, 50)(BLOCK_CHAR)
|
||||
const base = color === 'green' ? 120 : 50
|
||||
const fg = i => chalk.hsl(i * 3 + base, 100, 50)(BLOCK_CHAR2)
|
||||
|
||||
return _.range(BAR_LENGTH).map(i => i < w ? fg(i) : bg).join('')
|
||||
return BAR_BEFORE + _.range(BAR_LENGTH).map(i => i < w ? fg(i) : bg).join('') + BAR_AFTER
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user