Skip to content

Commit

Permalink
grunt: record git-revision in index.html
Browse files Browse the repository at this point in the history
  • Loading branch information
Nils Schneider committed Apr 19, 2015
1 parent 22b49c1 commit 071cd3f
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 2 deletions.
18 changes: 17 additions & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
@@ -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"])
}
Expand Down
3 changes: 3 additions & 0 deletions html/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
<link rel="stylesheet" href="style.css">
<script src="vendor/es6-shim/es6-shim.min.js"></script>
<script src="app.js"></script>
<script>
console.log("Version: #revision#")
</script>
</head>
<body>
</body>
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
5 changes: 5 additions & 0 deletions tasks/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -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/",
Expand Down

0 comments on commit 071cd3f

Please sign in to comment.