srs / gradle-gulp-plugin

Gradle plugin for running Gulp tasks
70 stars 9 forks source link

Can't Seem to Spawn Node Child Processes #2

Open nkoterba opened 9 years ago

nkoterba commented 9 years ago

I'm no Gradle or Gulp expert. However, it seems that child_process.spawn does not work in a gulp task when run from gradle.

I'm using gulp-install to run 'npm install' on some subdirectories:

var gulp = require('gulp');
var install = require('gulp-install');
var config = require('../gulp-config').installModules;
var print = require('gulp-print');

gulp.task('installModules', function () {
    gulp.src(config.src)
        .pipe(print())
        .pipe(install());
});

When I run this task from the terminal/CL using 'gulp installModules', everything works fine and the 'npm install' command is successfully run for each of my package.json files. Here is my output:

[12:08:29] Using gulpfile /Volumes/tempb/SNAP/Code/code/webclient/gulpfile.js
[12:08:29] Starting 'installModules'...
[12:08:29] Finished 'installModules' after 6.64 ms
[gulp] app/scripts/a/package.json
[gulp] app/scripts/b/package.json
[gulp] app/scripts/c/package.json
emitter-component@1.1.1 node_modules/emitter-component
keycharm@0.2.0 node_modules/keycharm
moment@2.9.0 node_modules/moment
hammerjs@1.1.3 node_modules/hammerjs

However, when I run the exact same task using the gradle gulp plugin:

gradle gulp_installModules

I get:

:code:webclient:nodeSetup UP-TO-DATE
:code:webclient:installGulp UP-TO-DATE
:code:webclient:npmSetup UP-TO-DATE
:code:webclient:npmInstall
:code:webclient:gulp_installModules
[12:11:07] Using gulpfile /Volumes/tempb/SNAP/Code/code/webclient/gulpfile.js
[12:11:07] Starting 'installModules'...
[12:11:07] Finished 'installModules' after 5.22 ms
[gulp] app/scripts/a/package.json
[gulp] app/scripts/b/package.json
[gulp] app/scripts/c/package.json

BUILD SUCCESSFUL

Total time: 19.649 secs

The 'npm install' commands never executed and no dependencies are downloaded to my node_modules folder. In tracing the source code, it appears that the NODE child_process.spawn is being used internally by gulp-install:

var cmd = childProcess.spawn(cmdpath, command.args, {stdio: 'inherit', cwd: command.cwd || process.cwd()});

While I don't get any errors or issues, it appears that the child_process.spawn task immediately exits with status code 0, but doesn't actually execute the 'npm install' command.

Any ideas? Thoughts? Anyone else see this?