Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/batch-file/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在当前gulpfile中运行另一个gulpfile_Gulp - Fatal编程技术网

如何在当前gulpfile中运行另一个gulpfile

如何在当前gulpfile中运行另一个gulpfile,gulp,Gulp,在当前gulp文件中的“默认”任务之前,我需要运行另一个gulp文件。是否有任何gulp插件可用于此情况。您可以使用CLI API从控制台运行这两个gulp任务。有Gulp.run,但该函数已被弃用,并将继续删除 此代码段将连续运行下面的两个gulp文件 运行-two-gulp-files.js 要运行:节点运行两个gulp文件.js var exec = require('child_process').exec; // Run the dependency gulp file first

在当前gulp文件中的“默认”任务之前,我需要运行另一个gulp文件。是否有任何gulp插件可用于此情况。

您可以使用CLI API从控制台运行这两个gulp任务。有
Gulp.run
,但该函数已被弃用,并将继续删除

此代码段将连续运行下面的两个gulp文件

运行-two-gulp-files.js 要运行:
节点运行两个gulp文件.js

var exec = require('child_process').exec;

// Run the dependency gulp file first
exec('gulp --gulpfile ./other-thing-with-gulpfile/gulpfile.js', function(error, stdout, stderr) {
    console.log('other-thing-with-gulpfile/gulpfile.js:');
    console.log(stdout);
    if(error) {
        console.log(error, stderr);
    }
    else {

        // Run the main gulp file after the other one finished
        exec('gulp --gulpfile ./gulpfile.js', function(error, stdout, stderr) {
            console.log('gulpfile.js:');
            console.log(stdout);
            if(error) {
                console.log(error, stderr);
            }
        });
    }
});
/gulpfile.js
取决于使用gulpfile/gulpfile.js的
/其他东西

var exec = require('child_process').exec;

// Run the dependency gulp file first
exec('gulp --gulpfile ./other-thing-with-gulpfile/gulpfile.js', function(error, stdout, stderr) {
    console.log('other-thing-with-gulpfile/gulpfile.js:');
    console.log(stdout);
    if(error) {
        console.log(error, stderr);
    }
    else {

        // Run the main gulp file after the other one finished
        exec('gulp --gulpfile ./gulpfile.js', function(error, stdout, stderr) {
            console.log('gulpfile.js:');
            console.log(stdout);
            if(error) {
                console.log(error, stderr);
            }
        });
    }
});
gulpfile.js 使用gulpfile/gulpfile.js的其他内容
var gulp = require('gulp');
var replace = require('gulp-replace');

gulp.task('file2-txt', function() {
    return gulp.src('file2.txt')
        .pipe(replace(/baz/g, 'qux'))
        .pipe(gulp.dest('../dest'));
});

gulp.task('default', ['file2-txt']);