grunt: record git-revision in index.html

This commit is contained in:
Nils Schneider 2015-04-19 12:55:14 +02:00
parent 22b49c1a55
commit 071cd3fe69
4 changed files with 27 additions and 2 deletions

View file

@ -1,7 +1,23 @@
module.exports = function (grunt) { 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.loadTasks("tasks")
grunt.registerTask("default", ["lint", "copy", "sass", "requirejs"]) grunt.registerTask("default", ["lint", "saveRevision", "copy", "sass", "requirejs"])
grunt.registerTask("lint", ["eslint"]) grunt.registerTask("lint", ["eslint"])
grunt.registerTask("dev", ["default", "connect:server", "watch"]) grunt.registerTask("dev", ["default", "connect:server", "watch"])
} }

View file

@ -9,6 +9,9 @@
<link rel="stylesheet" href="style.css"> <link rel="stylesheet" href="style.css">
<script src="vendor/es6-shim/es6-shim.min.js"></script> <script src="vendor/es6-shim/es6-shim.min.js"></script>
<script src="app.js"></script> <script src="app.js"></script>
<script>
console.log("Version: #revision#")
</script>
</head> </head>
<body> <body>
</body> </body>

View file

@ -14,7 +14,8 @@
"grunt-contrib-sass": "^0.9.2", "grunt-contrib-sass": "^0.9.2",
"grunt-contrib-uglify": "^0.5.1", "grunt-contrib-uglify": "^0.5.1",
"grunt-contrib-watch": "^0.6.1", "grunt-contrib-watch": "^0.6.1",
"grunt-eslint": "^10.0.0" "grunt-eslint": "^10.0.0",
"grunt-git-describe": "^2.3.2"
}, },
"eslintConfig": { "eslintConfig": {
"env": { "env": {

View file

@ -2,6 +2,11 @@ module.exports = function(grunt) {
grunt.config.merge({ grunt.config.merge({
copy: { copy: {
html: { html: {
options: {
process: function (content) {
return content.replace("#revision#", grunt.option("gitRevision"))
}
},
src: ["*.html"], src: ["*.html"],
expand: true, expand: true,
cwd: "html/", cwd: "html/",