Skip to content

Commit

Permalink
Version number injected in sources (mainly used in Live version)
Browse files Browse the repository at this point in the history
  • Loading branch information
psychowood committed May 15, 2016
1 parent 75aa8b3 commit d631d95
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 5 deletions.
12 changes: 12 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,17 @@ module.exports = function (grunt) {
replacement: 'href="http://psychowood.github.io/ng-torrent-ui/dist/remoted-resources/styles/'
}]
}
},
version: {
files: {
'.tmp/concat/scripts/scripts.js': '.tmp/concat/scripts/scripts.js'
},
options: {
replacements: [{
pattern: 'ntuConst.version = undefined',
replacement: 'ntuConst.version = "' + appConfig.version + '"'
}]
}
}
},

Expand Down Expand Up @@ -636,6 +647,7 @@ module.exports = function (grunt) {
'concat',
'ngAnnotate',
'copy:dist',
'string-replace:version',
'cdnify',
'cssmin',
'uglify'
Expand Down
19 changes: 14 additions & 5 deletions app/scripts/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ angular
starredItems: 'starredItems',
lastFilters: 'lastFilters',
lastSorter: 'lastSorter'
}).config(function(toastrConfig) {
}).run(['ntuConst', function(ntuConst) {
// don't touch the line below, version will be injected
ntuConst.version = undefined;
}]).config(function(toastrConfig) {
angular.extend(toastrConfig, {
allowHtml: true
});
Expand Down Expand Up @@ -174,9 +177,8 @@ angular
return true;
};


$http.get('bower.json').then(function(res) {
var currentVersion = 'v' + res.data.version;
var versionChecker = function(version) {
var currentVersion = 'v' + version;
if ($cookies.get('currentVersion') !== currentVersion) {
lastUpdateCheck = undefined;
$cookies.remove('updatedVersion');
Expand Down Expand Up @@ -222,8 +224,15 @@ angular
} else {
$log.info('Version already checked in the last hour');
}
};

});
if(ntuConst.version) {
versionChecker(ntuConst.version);
} else {
$http.get('bower.json').then(function(res) {
versionChecker(res.data.version);
});
}

$scope.updatedVersion = $cookies.get('updatedVersion');

Expand Down

0 comments on commit d631d95

Please sign in to comment.