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
?
太好了,謝謝。在結束