callerc1 / shipit-npm

Npm tasks for shipit.
MIT License
21 stars 12 forks source link

npm_preinstall event not working with asynchronous tasks #8

Closed timkelty closed 9 years ago

timkelty commented 9 years ago

I haven't time to dig into the shipit-npm code, but here's what I'm trying to do:

var config = {
  npm: {
    preinstall: true,
    installFlags: '--production'
  }
}

shipit.on('npm_preinstall', function() {
  console.log('npm_pre_install');
  shipit.start('shared', function() {
    shipit.emit('npm_pre_install_complete');
  });
});

So, on npm_preinstall, I want to:

What is acutally happening is:

Finished 'deploy:update' after 12 s

Running 'npm:preinstall' task...
npm_pre_install
Finished 'npm:preinstall' after 345 μs
...
Running 'shared:create-dirs' task...
...
Running 'deploy:publish' task...
...
Finished 'deploy' [ deploy:init, deploy:fetch, deploy:update, deploy:publish, deploy:clean ]
Running 'npm:install' task...
Installing npm modules.
Running "node -v && cd /home/edwards/apps/website/development/releases/20150709151848 && npm i --production" on host "edwards.fusionarydev.com".
@edwards.fusionarydev.com v0.10.37
npm install complete
Finished 'npm:install' after 2.06 s

Running 'npm:install' task...
...
Running 'npm:install' task...
...

Any ideas?

timkelty commented 9 years ago

With #9, this issue would be fixed by simply doing this in your shipit config:

    npm: {
      triggerEvent: 'shared',
      installFlags: '--production'
    },

I'm doing the same thing in shipit-shared

Personally, I prefer this and think it is ultimately more flexible. Let me know what you think!

callerc1 commented 9 years ago

fixed with https://github.com/callerc1/shipit-npm/pull/9