Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add callback function support for generator scheduling #521

Merged
merged 9 commits into from
Mar 9, 2024

Conversation

dwarakaprasad
Copy link
Contributor

@dwarakaprasad dwarakaprasad commented Mar 9, 2024

depends on yeoman/yeoman-api#6
required by jhipster/generator-jhipster#25445

This PR allows a callback function as an option for ComposeOptions.schedule

The function receives the generator instance as the parameter and must return a boolean that will decide the scheduling. A true return value schedules the generator to be run under environment:run loop and a false queues the generator tasks immediately.

usage:

env.composeWith('hello:world', { schedule: (generator) => {
    // some code to decide the scheduling option
   return generator.immediate;
}});

src/environment-base.ts Outdated Show resolved Hide resolved
src/environment-base.ts Outdated Show resolved Hide resolved
@mshima
Copy link
Member

mshima commented Mar 9, 2024

Please add test for function returning false since a function is truthy.

current tests are in:

describe('passing false schedule parameter', () => {
it('should not schedule generator', async function () {
this.env.queueTask = sinon.spy();
await this.env.composeWith('stub', { generatorArgs: [], schedule: false });
if (isGreaterThan6(generatorVersion)) {
assert(this.env.queueTask.calledOnce);
assert(this.env.queueTask.getCall(0).firstArg !== 'environment:run');
} else {

@mshima mshima merged commit 1c3ff69 into yeoman:main Mar 9, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants