Code Monkey home page Code Monkey logo

Comments (7)

dodtsair avatar dodtsair commented on September 13, 2024

I ran into this as well.

Currently I have one project which is used to run some sub projects. Like the follow

  1. rootProject/
  2. rootProject/gulpfile.js
  3. rootProject/subProject1/
  4. rootProject/subProject1/gulfile.js
  5. rootProject/subProject2/
  6. rootProject/subProject2/gulfile.js

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

cd rootProject/
npm install
pushd subProject1
npm install
popd
pushd subProject2
npm install
popd
gulp

I was hoping I could change this to

cd rootProject/
npm install
gulp

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.

from gulp-install.

dodtsair avatar dodtsair commented on September 13, 2024

Looking at the code I see the use of through2. That object is returned from the call to install(). It looks like the code calls callbacks whenever npm install is done executing. So it looks like I am putting my callback in the wrong place.

Here is what my code looks like:

modules.forEach(function(module) {
  gulp.task(module + "-npm-install", function(cb) {
    var installPipe = install()
    gulp.src(['./' + module + '/package.json']).pipe(installPipe)
    installPipe.on("finish", cb);
  });
});

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

[12:20:24] Starting 'subProject1-npm-install'...
....
[12:20:24] Finished 'subProject1-npm-install' after 19 ms

Gulp has obviously decided that gulp-install finished well before its calls to npm install finished.

from gulp-install.

roh85 avatar roh85 commented on September 13, 2024

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
    });
});

from gulp-install.

maxfrigge avatar maxfrigge commented on September 13, 2024

Another major use case for this is to restart your application after the modules have been installed.

from gulp-install.

vtange avatar vtange commented on September 13, 2024

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

from gulp-install.

tliebscher avatar tliebscher commented on September 13, 2024

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.
The following tasks then just don't find the directories and files.

Is there a way to make the execution of gulp-install blocking?

from gulp-install.

swinston1000 avatar swinston1000 commented on September 13, 2024

Callback support would be very useful - is there any reason that this has not been merged - #31 ???
Thanks!

from gulp-install.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.