forked from cheeaun/hackerweb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbumpAppCache.js
40 lines (32 loc) · 1.04 KB
/
bumpAppCache.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
'use strict';
module.exports = function(grunt){
grunt.registerMultiTask('bumpAppCache', 'Bump the AppCache version', function(){
var options = this.options();
var rVersion = options.rVersion;
var format = options.format;
if (!rVersion || !format){
grunt.log.warn('No options set.');
return;
}
var customVersion = grunt.option('custom');
this.filesSrc.forEach(function(f){
var file = grunt.file.read(f);
var content = '';
if (customVersion){
grunt.log.writeln('Writing AppCache with custom version: ' + customVersion);
content = file.replace(rVersion, function(match, version){
return match.replace(version, customVersion);
});
} else {
grunt.log.writeln('Writing AppCache with new version.');
content = file.replace(rVersion, format);
}
if (file != content){
grunt.file.write(f, content);
grunt.log.writeln('File "' + f + '" modified with new version.');
} else {
grunt.log.writeln('File "' + f + '" not modified.');
}
});
});
};