Skip to content

Instantly share code, notes, and snippets.

@yashprit
Last active August 29, 2015 14:05
Show Gist options
  • Save yashprit/c49a00aab38df3eefd2e to your computer and use it in GitHub Desktop.
Save yashprit/c49a00aab38df3eefd2e to your computer and use it in GitHub Desktop.
gulp task for reading git SHA1
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