Skip to content

Commit

Permalink
Inject build version into JS root scope.
Browse files Browse the repository at this point in the history
  • Loading branch information
Dimitar Dimitrov committed Apr 25, 2016
1 parent ac5ef88 commit 569b1d0
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -16,3 +16,4 @@ node_modules/
rdf_editor_dav.vad
rdf_editor_pkg.tar.gz
rdf_editor_pkg.zip
gen_version
22 changes: 21 additions & 1 deletion Gruntfile.js
Expand Up @@ -329,6 +329,25 @@ module.exports = function (grunt) {
}
},

'string-replace': {
dist: {
files: {
'dist/': '<%= yeoman.dist %>/scripts/{,*/}*.js'
},
options: {
replacements: [
{
pattern: '##VERSION##',
replacement: function (match, param) {
var gen_version = grunt.file.read('gen_version');
return gen_version.substring(0, gen_version.length-1);
}
}
]
}
}
},

// Copies remaining files to places other tasks can use
copy: {
dist: {
Expand Down Expand Up @@ -441,7 +460,8 @@ module.exports = function (grunt) {
'uglify',
'filerev',
'usemin',
'htmlmin'
'htmlmin',
'string-replace'
]);

grunt.registerTask('default', [
Expand Down
7 changes: 4 additions & 3 deletions Makefile.am
Expand Up @@ -31,7 +31,6 @@ PKG_NAME = rdf_editor_pkg
#
VERSION = `./gen_version.sh`


#
# What packages to build
#
Expand All @@ -48,6 +47,7 @@ RDF_EDITOR_FILES = dist/index.html
GRUNT_FILES = \
app/styles/*.css \
css/*.css \
app/views/*.html \
app/scripts/*.js \
app/scripts/controllers/*.js \
src/deps-orig/*.js \
Expand All @@ -58,7 +58,8 @@ GRUNT_FILES = \
app/data/*.ttl \
app/config.json

dist/index.html: $(GRUNT_FILES) $(BOWER_DIR)
dist/index.html: Gruntfile.js $(GRUNT_FILES) $(BOWER_DIR)
./gen_version.sh > gen_version
grunt build

$(BOWER_DIR): $(MODULE_DIR) bower.json
Expand Down Expand Up @@ -150,13 +151,13 @@ RDF_EDITOR_DIST = \
app/*.json \
app/data/*.ttl \
app/*.html \
app/views/*.html \
app/images/*.gif \
app/images/*.png \
app/scripts/controllers/*.js \
app/scripts/*.js \
app/styles/*.css \
app/tmpl/*.html \
app/views/*.html \
css/bootstrap.css.map \
css/bootstrap-theme.css.map \
css/*.css \
Expand Down
4 changes: 4 additions & 0 deletions app/scripts/app.js
Expand Up @@ -13,6 +13,10 @@ angular.module('myApp', [
$routeProvider.otherwise({redirectTo: '/welcome'});
}])

.run(function($rootScope) {
$rootScope.version = '##VERSION##';
})

.factory('Notification', function() {
// set defaults
$.notifyDefaults({
Expand Down
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -24,6 +24,7 @@
"grunt-karma": "^0.10.1",
"grunt-newer": "^1.1.0",
"grunt-ng-annotate": "^0.9.2",
"grunt-string-replace": "^1.2.1",
"grunt-svgmin": "^2.0.0",
"grunt-usemin": "^3.0.0",
"grunt-wiredep": "^2.0.0",
Expand Down

0 comments on commit 569b1d0

Please sign in to comment.