Skip to content

Instantly share code, notes, and snippets.

@lauripiispanen
Created January 21, 2013 14:52
Show Gist options
  • Save lauripiispanen/4586616 to your computer and use it in GitHub Desktop.
Save lauripiispanen/4586616 to your computer and use it in GitHub Desktop.
// tasks/git_rev.js
"use strict";
var exec = require('child_process').exec;
module.exports = function(grunt) {
grunt.registerTask("git-rev", "Get the current Git rev", function(prop) {
var done = this.async();
exec('git rev-parse HEAD', function(error, stdout, stderr) {
grunt.template.git = {
rev: stdout
};
done();
});
});
};
// grunt.js
...
meta: {
banner: '/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - ' +
'<%= grunt.template.today("yyyy-mm-dd") %>\n' +
'<%= pkg.homepage ? "* " + pkg.homepage + "\n" : "" %>' +
'* Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>; rev <%= grunt.template.git.rev %>' +
' Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %> */'
},
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment