【发布时间】:2014-07-12 22:40:45
【问题描述】:
所以我有以下所有与安装和复制 bower 文件相关的 GulpJS 任务:
gulp.task('bower-install', function() {
var command = 'bower install';
gutil.log(gutil.colors.cyan('running command:'), command);
return gulp.src('', {read: false})
.pipe(shell([
command
]));
});
gulp.task('bower-copy', function() {
return gulp.src(gulpConfig.bowerCopy.map(function(item) {
return './bower_components/' + item;
}), {base: './bower_components'})
.pipe(gulp.dest('./htdocs/components'));
});
gulp.task('bower-copy-clean', function() {
return gulp.src('./bower_components')
.pipe(clean());
});
gulp.task('bower-clean', function() {
return gulp.src('./htdocs/components')
.pipe(clean());
});
gulp.task('bower', 'Download and move bower packages', function(done) {
runSequence(
'bower-install',
'bower-clean',
'bower-copy',
'bower-copy-clean',
done
);
});
我这样做是因为我需要这些任务一个接一个地依次运行。虽然当我运行 gulp bower 时一切都按预期工作,但我想构造这段代码,以便唯一暴露的任务是 bower,因为所有 bower-* 自己运行毫无意义。
有没有办法编写这段代码,让所有bower-* 任务一个接一个地运行,但只公开bower 任务?
【问题讨论】: