Skip to content

Commit

Permalink
fix: fix globalState bug
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Nov 4, 2018
1 parent f96ad47 commit 8c0441b
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/plugin.js
Expand Up @@ -43,15 +43,13 @@ export default class WebpackBarPlugin extends ProgressPlugin {
};

// Keep our state in shared ojbect
this.states = globalStates;
if (!this.states[this.options.name]) {
this.states[this.options.name] = {
...DEFAULT_STATE,
color: this.options.color,
name: startCase(this.options.name),
};
}
this.state = this.states[this.options.name];

// Reporters
this.reporters = Array.from(this.options.reporters || []);
Expand Down Expand Up @@ -127,6 +125,14 @@ export default class WebpackBarPlugin extends ProgressPlugin {
);
}

get states() {
return globalStates;
}

get state() {
return globalStates[this.options.name];
}

apply(compiler) {
super.apply(compiler);

Expand All @@ -144,7 +150,6 @@ export default class WebpackBarPlugin extends ProgressPlugin {
Object.assign(this.state, {
...DEFAULT_STATE,
start: process.hrtime(),
_allDoneCalled: false,
});

this.callReporters('start');
Expand Down

0 comments on commit 8c0441b

Please sign in to comment.