From fab9b44890038adf483e2e33e50fb82ade7fd6a6 Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Tue, 13 Mar 2018 12:15:46 +0330 Subject: [PATCH] improve progress --- lib/builder/webpack/plugins/progress.js | 67 +------------------------ 1 file changed, 1 insertion(+), 66 deletions(-) diff --git a/lib/builder/webpack/plugins/progress.js b/lib/builder/webpack/plugins/progress.js index 5dbdc8a00b..517c709ea9 100644 --- a/lib/builder/webpack/plugins/progress.js +++ b/lib/builder/webpack/plugins/progress.js @@ -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 -// } -// }