From 2241cd7e35fa0fc330008b58f1dd83c3db687402 Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Fri, 2 Nov 2018 12:32:45 +0330 Subject: [PATCH] fix: fix hasRunning and and hasErrors --- src/plugin.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/plugin.js b/src/plugin.js index dd65e2f..e70202d 100644 --- a/src/plugin.js +++ b/src/plugin.js @@ -70,10 +70,14 @@ export default class WebpackBarPlugin extends webpack.ProgressPlugin { } } - get hasRunning() { - return Object.keys(this.states) - .map((e) => this.states[e]) - .find((s) => s.isRunning); + hasRunning() { + return this.states.some((state) => state.isRunning); + } + + hasErrors() { + return Object.values(context.states).some( + (state) => state.stats && state.stats.hasErrors() + ); } apply(compiler) { @@ -81,7 +85,7 @@ export default class WebpackBarPlugin extends webpack.ProgressPlugin { const hook = (stats) => { this.state.stats = stats; - if (!this.hasRunning) { + if (!this.hasRunning()) { this.callReporters('done'); } };