Created
December 9, 2015 10:43
-
-
Save michaelwills/8148974848df6295241e to your computer and use it in GitHub Desktop.
append git commit to index.html with gulp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// http://stackoverflow.com/a/27084400 | |
var gulp = require('gulp'), | |
git = require('gulp-git'), | |
cheerio = require('gulp-cheerio'); | |
var gitHash; | |
gulp.task('hash', function(cb) { | |
return git.revParse({args:'--short HEAD'}, function(err, hash) { | |
gitHash = hash; | |
cb(); | |
}); | |
}); | |
gulp.task('html', ['hash'], function() { | |
return gulp.src('app/index.html') | |
.pipe(cheerio(function($) { | |
$('body').append('<p>' + gitHash + '</p>'); | |
})) | |
.pipe(gulp.dest('dist')); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment