mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-11 08:33:53 +00:00
improve progress
This commit is contained in:
parent
1a0d263180
commit
fab9b44890
@ -1,17 +1,11 @@
|
||||
const ProgressBar = require('node-progress-bars')
|
||||
const webpack = require('webpack')
|
||||
const throttle = require('lodash/debounce')
|
||||
const throttle = require('lodash/throttle')
|
||||
|
||||
module.exports = class ProgressPlugin extends webpack.ProgressPlugin {
|
||||
constructor(options) {
|
||||
super(options)
|
||||
|
||||
if (typeof options === 'function') {
|
||||
options = {
|
||||
handler: options
|
||||
}
|
||||
}
|
||||
|
||||
this.handler = (percent, msg) => this.updateProgress(percent, msg)
|
||||
|
||||
this.options = options || {}
|
||||
@ -21,9 +15,6 @@ module.exports = class ProgressPlugin extends webpack.ProgressPlugin {
|
||||
// BUG: plugin.appy is being called twice!
|
||||
// So initialize progress here
|
||||
this.startProgress()
|
||||
|
||||
this.lastPrgoress = 0
|
||||
this.lastMsg = ''
|
||||
}
|
||||
|
||||
updateProgress(percent, msg) {
|
||||
@ -31,15 +22,6 @@ module.exports = class ProgressPlugin extends webpack.ProgressPlugin {
|
||||
this.startProgress()
|
||||
}
|
||||
|
||||
const progress = Math.floor(percent * 100)
|
||||
|
||||
if (progress === this.lastPrgoress || msg === this.lastMsg) {
|
||||
return
|
||||
}
|
||||
|
||||
this.lastPrgoress = progress
|
||||
this.lastMsg = msg
|
||||
|
||||
if (percent === 1) {
|
||||
this.stopProgress()
|
||||
return
|
||||
@ -75,50 +57,3 @@ module.exports = class ProgressPlugin extends webpack.ProgressPlugin {
|
||||
this.bar = undefined
|
||||
}
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------
|
||||
// Shared console utils
|
||||
// -----------------------------------------------------------
|
||||
// let consoleSpied = 0
|
||||
|
||||
// const silentConsole = {}
|
||||
// const originalConsole = {}
|
||||
// const consoleQueue = {
|
||||
// log: [],
|
||||
// warn: [],
|
||||
// error: []
|
||||
// }
|
||||
|
||||
// // level: log, warn, error
|
||||
// Object.keys(consoleQueue).forEach((level) => {
|
||||
// silentConsole[level] = (...args) => consoleQueue[level].push(args)
|
||||
// originalConsole[level] = console[level] // eslint-disable-line no-console
|
||||
// })
|
||||
|
||||
// const muteConsole = () => {
|
||||
// // eslint-disable-next-line no-console
|
||||
// if (console.spiedInTest) {
|
||||
// return
|
||||
// }
|
||||
|
||||
// consoleSpied++
|
||||
|
||||
// Object.assign(console, silentConsole)
|
||||
// }
|
||||
|
||||
// const restoreConsole = () => {
|
||||
// if (consoleSpied === 0) {
|
||||
// return
|
||||
// }
|
||||
|
||||
// consoleSpied--
|
||||
|
||||
// Object.assign(console, originalConsole)
|
||||
|
||||
// // level: log, warn, error
|
||||
// for (let level in consoleQueue) {
|
||||
// const q = consoleQueue[level]
|
||||
// consoleQueue[level] = []
|
||||
// q.forEach(args => console[level](...args)) // eslint-disable-line no-console
|
||||
// }
|
||||
// }
|
||||
|
Loading…
Reference in New Issue
Block a user