I use Grunt and Grunt-shell to create / deploy my Javascript project.
I want to get the last git -commit number and save it as a variable, but I can not determine how to do it. I tried to have a callback and set a global variable. This variable is used inside the function, but not from inside another block.
grunt.initConfig({ ... shell: { getGitCommitNo: { command: 'git rev-parse --short HEAD', options: { callback: function (err, stdout, stderr, cb) { global['gitCommitNo'] = stdout; grunt.log.ok(global.gitCommitNo); cb(); } } }, philTest: { command: 'echo Git Commit No: ' + global.gitCommitNo }, ... }
Output:
>> Starting deployment process for version 1.1 in dev environment Running "shell:getGitCommitNo" (shell) task bfc82a9 >> bfc82a9 Running "shell:printTest" (shell) task Git Commit No: undefined Done, without errors.
Can anyone suggest how I can save the command line output for a variable that can be used?
source share