Created
August 30, 2016 16:23
-
-
Save areichman/7ea44e8e1819f2ab31ee6eeb44cea319 to your computer and use it in GitHub Desktop.
Grunt task to get a repo's short Git hash
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
'use strict'; | |
module.exports = function(grunt) { | |
grunt.task.registerTask('githash', function() { | |
var done = this.async(); | |
grunt.util.spawn({ | |
cmd: 'git', | |
args: ['rev-parse', '--short', 'HEAD'] | |
}, function(err, result, code) { | |
if (err) { | |
grunt.log.error(err); | |
done(false); | |
} else { | |
grunt.config('githash', result); | |
grunt.log.writeln('At revision ' + result); | |
done(true); | |
} | |
}); | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment