Skip to content
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

gulp-run doesn't work when child process changes working directory #44

Open
mirik123 opened this issue Aug 30, 2016 · 0 comments
Open

Comments

@mirik123
Copy link

The problem occurs because the child gulp script requires working directory change:
gulp --gulpfile "<...>\gulpfile.js" build
[13:40:01] Working directory changed to <...>
[13:40:03] Using gulpfile <...>\gulpfile.js
[13:40:03] Starting 'build'...
[13:40:03] Finished 'build' after 6.42 μs

This works:

const cp = require('cp');
gulp.task('gg2', function (done) {
    var gulpfile = path.join(gulpcwd, 'gulpfile.js'); 
    var subShell = cp.spawn('cmd.exe', ['/C', 'gulp', '--gulpfile', gulpfile, '--cwd', gulpcwd, 'build'], {
        env: process.env,
        cwd: process.cwd()
    });

    subShell.stdout.pipe(process.stdout);
    subShell.stderr.pipe(process.stderr);
    subShell.once('exit', function (code) {
            done(code);       
    });
});

This doesn’t work:

const run = require('gulp-run');
gulp.task('gg2', function (done) {
    var gulpfile = path.join(gulpcwd, 'gulpfile.js');
    return run('gulp --gulpfile "' + gulpfile + '" --cwd "' + gulpcwd + '" build', { verbosity: 3 })
        .exec(function (err) {
            done(err);
        }); 
});

In latter case the child process sends a standard gulp error that the gulp file is not found.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant