Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@michaelwills
Created December 9, 2015 10:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save michaelwills/8148974848df6295241e to your computer and use it in GitHub Desktop.
Save michaelwills/8148974848df6295241e to your computer and use it in GitHub Desktop.
append git commit to index.html with gulp
// 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