如何在当前gulpfile中运行另一个gulpfile
在当前gulp文件中的“默认”任务之前,我需要运行另一个gulp文件。是否有任何gulp插件可用于此情况。您可以使用CLI API从控制台运行这两个gulp任务。有如何在当前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.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']);