Javascript 一饮而尽
我遇到了一个问题,我有一个shell脚本的任务,还有一些我想按顺序运行的其他任务。我通过包含运行序列插件解决了常规任务的这个问题。但是这个插件的问题是,每个任务都应该返回一个流,这与我的shell任务不同(我不能在其中返回流)。我需要在其他任务完成后运行我的“打包”任务,所以我尝试了此选项Javascript 一饮而尽,javascript,node.js,gulp,gulp-shell,Javascript,Node.js,Gulp,Gulp Shell,我遇到了一个问题,我有一个shell脚本的任务,还有一些我想按顺序运行的其他任务。我通过包含运行序列插件解决了常规任务的这个问题。但是这个插件的问题是,每个任务都应该返回一个流,这与我的shell任务不同(我不能在其中返回流)。我需要在其他任务完成后运行我的“打包”任务,所以我尝试了此选项 gulp.task('pack', ['build'], function () { shell.task(config.packHtml.cmdLineString) }); 但我的“打包”任务
gulp.task('pack', ['build'], function () {
shell.task(config.packHtml.cmdLineString)
});
但我的“打包”任务似乎不能正常工作。这是全部代码
var gulp = require('gulp'),
concat = require('gulp-concat'),
runSequence = require('run-sequence'),
order = require('gulp-order'),
replace = require('gulp-replace'),
uglify = require('gulp-uglify'),
combiner = require('stream-combiner2'), //NOTE: alternative to merge-stream
rename = require('gulp-rename'),
shell = require('gulp-shell'),
config = require('./config');
gulp.task('build', function () {
runSequence('concat', 'replace');
});
gulp.task('concat', function () {
var combined = combiner.obj([
gulp.src(config.concat.src),
order(config.concat.order, {base: './'}),
concat(config.concat.fileName),
gulp.dest(config.concat.dest)
]);
combined.on('error', console.error.bind(console));
return combined;
});
gulp.task('replace', function () {
var combined = combiner.obj([
gulp.src([config.replace.dest + '/' + config.replace.fileName]),
replace(config.replace.regExpForInclude, ''),
replace(config.replace.regExpForTarget, ''), //NOTE: make it in 1 regExp
gulp.dest(config.replace.dest)
]);
combined.on('error', console.error.bind(console));
return combined;
});
// gulp.task('pack',
// shell.task(config.packHtml.cmdLineString)
// );
gulp.task('pack', ['build'], function () {
shell.task(config.packHtml.cmdLineString)
});
有什么建议吗?我想用一个命令来运行所有任务(当然,如果我先运行“build”然后再运行“pack”,它会很好地工作) 我已经修好了。稍后我会补充答案。无论如何谢谢你!我已经修好了。稍后我会补充答案。无论如何谢谢你!