On deploy, Shipit checks out the current Git Sha, to a tmp directory, then I run npm install followed by gulp build, then proceed with the deploy.

Shipit uses Orchestrator for it's task flow, as Gulp does.

Shipit has it's own CLI, so I can deploy with shipit development deploy.

Everything thing above works. What I'm trying to do is create a gulp deploy task that will initialize Shipit directly, instead of using the CLI. Looks something like this:

gulp.task('shipit:deploy', function() {

var deployToEnv = argv['deploy-to'] || false;

var shipit;

return inquirer.prompt([{

type: 'list',

name: 'deployToEnv',

default: deployToEnv,

message: 'Deploy to environment:',

choices: envs

}]).then(function(answers) {

deployToEnv = answers.deployToEnv;

shipit = new Shipit({environment: deployToEnv});

shipit.initialize();

shipit.start('deploy');

});

});

Corresponding shipit config:

shipit.initConfig(config);

shipit.blTask('build', function() {

return shipit.local('npm install --silent', {

cwd: shipit.config.workspace

}).then(function() {

return shipit.local('gulp build', {

cwd: shipit.config.workspace

});

});

});

shipit.on('fetched', function() {

shipit.start('build');

});

Things appear to work with one problem: it doesn't actually perform the npm install!

Running "npm install --silent" on local.

Running "gulp build" on local.

So, it would seem something in the npm install command is prematurely resolving the promise, but I'm not sure how or why.

I had a similar problem (just using shipit cli) with npm warnings, which is when I discovered using the --silent arg solved that.

As a test, I left the code as is, but replaced npm install --silent with sleep 10. Sure enough, it waited for 10 seconds before executing gulp build. So, it would seem it is something specific with the npm install command.

Any help is appreciated!

Update #1:

shipit.local uses child_process.exec. I tried converting this to use child_process.spawn, but had the same result.

Update #2:

If I change the command to sudo npm install, things work as expected! So...what does this mean, and how can I avoid running it with sudo?

Update #3:

Still unable to do this without sudo, but I tried adding the --verbose flag with these results:

After update #2, I have more options to write why this combination don't work/ First of all, we need to figure out which user a execute the commands. To do this, you need to execute command whoami and see result (you can do it through ssh or shipit task). The direct question is what priveleges don't have user to install packages.