-
Notifications
You must be signed in to change notification settings - Fork 46
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
Callback once modules installed #17
Comments
I ran into this as well. Currently I have one project which is used to run some sub projects. Like the follow
Running gulp on rootProject runs it on each subproject. I have about three right now, but plan to add more. Before I can run gulp I need to install the npm modules
I was hoping I could change this to
This is what most people expect with a gulp project. However when I code gulp-install to call install on all the subprojects I don't see a way to run that serially with the actual gulp of that project. In the end npm install is running on subProject1 while gulp is called on it. This obviously blows up. Modules are still missing. |
Looking at the code I see the use of through2. That object is returned from the call to Here is what my code looks like:
I create a task for each module. I didn't include the code but the gulp call for each module depends on the module-npm-install task. So if the cb gets called at the right time, then the gulp call should not happen until after npm install finished. I put my callback on the "finish" event for the installPipe. It seems to get called because nothing hangs, but it gets called in milliseconds
Gulp has obviously decided that gulp-install finished well before its calls to npm install finished. |
I have the same issue. Used a timeout as a workaround to bypass this behaviour. A proper fix would be appreciated. gulp.task('install', function(cb){
var installPipe = install();
gulp.src(['./node_modules/subprojects/package.json'])
.pipe(installPipe);
installPipe.on("finish", function(){
if(dirs_exists(['./node_modules/subproject/node_modules'])){
CONST_TIMEOUT = 1000;
}
setTimeout(function() {
/*
Put tasks to execute here
*/
gulp.start('build')
gulp.start('images')
gulp.start('scripts')
gulp.start('styles')
},CONST_TIMEOUT); //use timeout to give npm install the chance to finish properly
});
}); |
Another major use case for this is to restart your application after the modules have been installed. |
Would really like this to be possible. Wanted to make a slush generator that does some extra steps after the .pipe(install()) part, but pretty much can't. Tried linking Gulp tasks in serial and using plugins like run-sequence. .pipe(install()) seems to force a hard stop on the process |
Creating task dependencies in gulp with the intention of blocking the following tasks until gulp-install has finished does not work, as gulp-install returns before e.g. bower even has started. Is there a way to make the execution of gulp-install blocking? |
Callback support would be very useful - is there any reason that this has not been merged - #31 ??? |
Would be nice if we could provide a callback to run once modules have been installed. I understand it might be difficult because you are spawning a new process for this. But it would be a great addition if possible
The text was updated successfully, but these errors were encountered: