From e9d0a150b279adc79a3c73d6f23b603f621535e2 Mon Sep 17 00:00:00 2001 From: Marcelo Boveto Shima Date: Wed, 17 Feb 2021 15:11:24 -0300 Subject: [PATCH] Remove support for chainning at composeWith. --- lib/index.js | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/lib/index.js b/lib/index.js index d0f53347..5c1e446f 100644 --- a/lib/index.js +++ b/lib/index.js @@ -1051,8 +1051,7 @@ class Generator extends Base { * Compose this generator with another one. * @param {String|Object|Array} generator The path to the generator module or an object (see examples) * @param {Object} [options] The options passed to the Generator - * @param {boolean} [returnNewGenerator] Returns the created generator instead of returning this. - * @return {this|Object} This generator or the composed generator when returnNewGenerator=true + * @return {Generator} The composed generator * * @example Using a peerDependency generator * this.composeWith('bootstrap', { sass: true }); @@ -1063,22 +1062,15 @@ class Generator extends Base { * @example Passing a Generator class * this.composeWith({ Generator: MyGenerator, path: '../generator-bootstrap/app/main.js' }, { sass: true }); */ - composeWith(generator, options, returnNewGenerator = false) { + composeWith(generator, options) { if (typeof options === 'boolean') { - returnNewGenerator = options; options = {}; } - const returnCompose = (returnValue) => - returnNewGenerator ? returnValue : this; - let instantiatedGenerator; if (Array.isArray(generator)) { - const generators = generator.map((gen) => - this.composeWith(gen, options, returnNewGenerator) - ); - return returnCompose(generators); + return generator.map((gen) => this.composeWith(gen, options)); } const instantiate = (Generator, path) => { @@ -1166,7 +1158,7 @@ class Generator extends Base { } if (!instantiatedGenerator) { - return returnCompose(instantiatedGenerator); + return instantiatedGenerator; } if (this._running) { @@ -1175,7 +1167,7 @@ class Generator extends Base { this._composedWith.push(instantiatedGenerator); } - return returnCompose(instantiatedGenerator); + return instantiatedGenerator; } /**