From baa1247b175b35e508b487ccc76972bb239ca8cf Mon Sep 17 00:00:00 2001 From: Rafal Kalicinski Date: Wed, 18 Oct 2017 14:00:25 +0200 Subject: [PATCH] Webpack apply method made synchronous --- .../auto-increase-version.js | 10 ++------- .../inject-as-comment/inject-as-comment.js | 1 - src/components/inject-by-tag/inject-by-tag.js | 1 - src/main.js | 22 +++++++++---------- 4 files changed, 13 insertions(+), 21 deletions(-) diff --git a/src/components/auto-increase-version/auto-increase-version.js b/src/components/auto-increase-version/auto-increase-version.js index b0fe310..eb9c977 100644 --- a/src/components/auto-increase-version/auto-increase-version.js +++ b/src/components/auto-increase-version/auto-increase-version.js @@ -23,12 +23,8 @@ export default class AutoIncreaseVersion { // we have to register AutoIncreaseVersion instead of firing it straight away if (config.componentsOptions.AutoIncreaseVersion.runInWatchMode) { if (this.context.compiler) { - this.context.compiler.plugin('emit', async (compilation, cb) => { - await new Promise((resolve, reject) => { - this.resolve = resolve; - this.reject = reject; - this.start(); - }); + this.context.compiler.plugin('emit', (compilation, cb) => { + this.start(); cb(); }); } @@ -58,8 +54,6 @@ export default class AutoIncreaseVersion { this.minor(); } else if (isArgv('patch')) { this.patch(); - } else { - this.resolve(); } } diff --git a/src/components/inject-as-comment/inject-as-comment.js b/src/components/inject-as-comment/inject-as-comment.js index 1686ae2..caa98b1 100644 --- a/src/components/inject-as-comment/inject-as-comment.js +++ b/src/components/inject-as-comment/inject-as-comment.js @@ -45,7 +45,6 @@ export default class InjectAsComment { } cb(); }); - return new Promise((resolve) => { resolve(); }); } parseTags(baseOpen, baseClose) { diff --git a/src/components/inject-by-tag/inject-by-tag.js b/src/components/inject-by-tag/inject-by-tag.js index 3d157e9..e278647 100644 --- a/src/components/inject-by-tag/inject-by-tag.js +++ b/src/components/inject-by-tag/inject-by-tag.js @@ -65,6 +65,5 @@ export default class InjectByTag { } cb(); }); - return new Promise((resolve) => { resolve(); }); } } diff --git a/src/main.js b/src/main.js index de94228..c2eae49 100644 --- a/src/main.js +++ b/src/main.js @@ -49,9 +49,9 @@ export default class WebpackAutoInject { * @param compiler * @protected */ - async apply(compiler) { + apply(compiler) { this.compiler = compiler; - await this.executeWebpackComponents(); + this.executeWebpackComponents(); } /** @@ -59,8 +59,8 @@ export default class WebpackAutoInject { * - runs as soon as possible, * > without waiting for webpack init */ - async executeNoneWebpackComponents() { - await this.executeComponent([AutoIncreaseVersion]); + executeNoneWebpackComponents() { + this.executeComponent([AutoIncreaseVersion]); } /** @@ -68,11 +68,11 @@ export default class WebpackAutoInject { * - runs when webpack is initialized * and plugins is called by webpack */ - async executeWebpackComponents() { + executeWebpackComponents() { if (config.componentsOptions.AutoIncreaseVersion.runInWatchMode) { - await this.executeComponent([AutoIncreaseVersion]); + this.executeComponent([AutoIncreaseVersion]); } - await this.executeComponent([InjectAsComment, InjectByTag]); + this.executeComponent([InjectAsComment, InjectByTag]); } /** @@ -80,7 +80,7 @@ export default class WebpackAutoInject { * - general layer for comp execution * - used for both, webpack and non webpack comp */ - async executeComponent(components) { + executeComponent(components) { // no more components, // finish if (!components.length) { @@ -92,7 +92,7 @@ export default class WebpackAutoInject { // if component is disabled, call next component if (!this.config.components[ComponentClass.componentName.toLowerCase()]) { - await this.executeComponent(components); + this.executeComponent(components); return; } @@ -100,10 +100,10 @@ export default class WebpackAutoInject { let inst = new ComponentClass(this); // await for apply to finish - await inst.apply(); + inst.apply(); // call next tick - await this.executeComponent(components); + this.executeComponent(components); } }