generator icon indicating copy to clipboard operation
generator copied to clipboard

Problem with installDependencies

Open lexich opened this issue 11 years ago • 8 comments

I have problem with installDependencies method. I researched this problem and found possible problem. I think that main problem in runInstall method

  }.bind(this), { once: installer + ' ' + args.join(' '), run: false });

https://github.com/yeoman/generator/blob/master/lib/actions/install.js#L52

After that I replaced run: false to run: true it would be all ok. I'm not understand infrastructure at all, I don't create pull request.

lexich avatar Jan 23 '15 13:01 lexich

This is not your issue.

Setting run to false just doesn't triggers a run on it's own unless yeoman launch the event loop.

Maybe try explaining the context of the problem you're having.

SBoudrias avatar Jan 23 '15 18:01 SBoudrias

Closing for now as this doesn't seem to be an issue with yeoman-generator. Feel free to continue the discussion if you need further support.

SBoudrias avatar Jan 25 '15 22:01 SBoudrias

Thx for help. I understand my problem. I use installDependencies after end event. But as i think event loop starts before this event.

//It's wrong
this.on('end', function () {
    this.installDependencies({ skipInstall: this.options['skip-install'] });
});

Main problem is that this code worked earlier, but now it's not problem))

//solution
//this.on('end', function () {
this.installDependencies({ skipInstall: this.options['skip-install'] });
//});

lexich avatar Jan 26 '15 08:01 lexich

@lexich I am experiencing the same issues as you in as much as installDependencies() works if I take it out of the this.on('end'. Is this okay to keep or is there a problem with the generator? Should we be waiting for another event to install deps?

mrmartineau avatar Feb 20 '15 12:02 mrmartineau

No, calling installDependencies automatically set up the run loop. The thing is that when the end event is triggered, the generator is done doing all it's work and won't run anything else.

Events are for external use (like platform integrating generators), not for the generator itself.

SBoudrias avatar Feb 20 '15 18:02 SBoudrias

@SBoudrias thanks, but just so I'm clear, will installDependencies always be called at the correct time? i.e after the generator has done everything else?

mrmartineau avatar Feb 21 '15 12:02 mrmartineau

Yes!

SBoudrias avatar Feb 21 '15 21:02 SBoudrias

Good to know, thanks.

mrmartineau avatar Feb 21 '15 21:02 mrmartineau