Skip to content

Commit

Permalink
Move _postConstruct from create to instantiate. (#382)
Browse files Browse the repository at this point in the history
  • Loading branch information
mshima authored Jan 18, 2022
1 parent 256e142 commit 66752e4
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions lib/environment.js
Original file line number Diff line number Diff line change
Expand Up @@ -764,16 +764,10 @@ class Environment extends Base {
};

maybeGenerator = maybeGenerator || this.get(namespaceOrPath);
if (maybeGenerator && (maybeGenerator.then || maybeGenerator.prototype._postConstruct)) {
if (maybeGenerator && maybeGenerator.then) {
return Promise.resolve(maybeGenerator)
.then(Generator => checkGenerator(Generator))
.then(Generator => this.instantiate(Generator, args, options))
.then(async generator => {
if (!options.help && generator._postConstruct) {
await generator._postConstruct();
}
return generator;
});
.then(Generator => this.instantiate(Generator, args, options));
}

return this.instantiate(checkGenerator(maybeGenerator), args, options);
Expand Down Expand Up @@ -816,6 +810,10 @@ class Environment extends Base {
...environmentOptions
};

if (!options.help && generator._postConstruct) {
return Promise.resolve(generator._postConstruct()).then(() => generator);
}

return generator;
}

Expand Down

0 comments on commit 66752e4

Please sign in to comment.