From 071cd3fe691627ca21af4fae3aceeaaa2fcc248a Mon Sep 17 00:00:00 2001 From: Nils Schneider Date: Sun, 19 Apr 2015 12:55:14 +0200 Subject: [PATCH] grunt: record git-revision in index.html --- Gruntfile.js | 18 +++++++++++++++++- html/index.html | 3 +++ package.json | 3 ++- tasks/build.js | 5 +++++ 4 files changed, 27 insertions(+), 2 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index cdce67d..3dfc70e 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -1,7 +1,23 @@ module.exports = function (grunt) { + grunt.loadNpmTasks("grunt-git-describe") + + grunt.initConfig({ + "git-describe": { + options: {}, + default: {} + } + }) + + grunt.registerTask("saveRevision", function() { + grunt.event.once("git-describe", function (rev) { + grunt.option("gitRevision", rev) + }) + grunt.task.run("git-describe") + }) + grunt.loadTasks("tasks") - grunt.registerTask("default", ["lint", "copy", "sass", "requirejs"]) + grunt.registerTask("default", ["lint", "saveRevision", "copy", "sass", "requirejs"]) grunt.registerTask("lint", ["eslint"]) grunt.registerTask("dev", ["default", "connect:server", "watch"]) } diff --git a/html/index.html b/html/index.html index 729a3a3..fc4ff6e 100644 --- a/html/index.html +++ b/html/index.html @@ -9,6 +9,9 @@ + diff --git a/package.json b/package.json index 9a662d7..5b54b11 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,8 @@ "grunt-contrib-sass": "^0.9.2", "grunt-contrib-uglify": "^0.5.1", "grunt-contrib-watch": "^0.6.1", - "grunt-eslint": "^10.0.0" + "grunt-eslint": "^10.0.0", + "grunt-git-describe": "^2.3.2" }, "eslintConfig": { "env": { diff --git a/tasks/build.js b/tasks/build.js index e36ecbd..b7b34be 100644 --- a/tasks/build.js +++ b/tasks/build.js @@ -2,6 +2,11 @@ module.exports = function(grunt) { grunt.config.merge({ copy: { html: { + options: { + process: function (content) { + return content.replace("#revision#", grunt.option("gitRevision")) + } + }, src: ["*.html"], expand: true, cwd: "html/",