Last active
August 29, 2015 14:05
-
-
Save yashprit/c49a00aab38df3eefd2e to your computer and use it in GitHub Desktop.
gulp task for reading git SHA1
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
gulp.task('add:deployment', function (cb) { | |
var command = 'git rev-parse HEAD'; | |
var deploymentFile = 'source/js/common/deployment.js'; | |
exec(command, function (err, stdout, stderr) { | |
if(err) { | |
cb(err); | |
gutil.log("Executing '" + command + " fails"); | |
throw new Error("error occured while executing command " + command); | |
} | |
var jsCode = "window.deploymentNumber = " + stdout; | |
fs.writeFile(deploymentFile, jsCode, function(err) { | |
if(err) { | |
gutil.log("Writing file " + deploymentFile); | |
throw new Error("error occured while executing command " + command); | |
} | |
gutil.log("Deployment number " + stdout + " is written to file " + deploymentFile); | |
}); | |
}); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment