3
我的目标是将最新的git commit添加到我的index.html
文件中。Gulp - 从另一个任务获取返回值
以下任务成功返回(使用)最新的git哈希:
var git = require('gulp-git');
gulp.task('hash', function() {
git.revParse({args:'--short HEAD'}, function (err, hash) {
return hash;
});
});
以下任务建立我的HTML:
var inject = require('inject-string');
gulp.task('html', function() {
return gulp.src('app/index.html')
.pipe(inject.append('append git hash here!'))
.pipe(gulp.dest('dist'))
});
这成功地将一个字符串追加到index.html
但我该怎么办将hash
任务的返回值注入html
?
太好了,谢谢。在结束