forked from natashawylie/iviewer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
75 lines (64 loc) · 1.77 KB
/
Gruntfile.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
module.exports = function(grunt) {
var fs = require('fs')
, version = fs.readFileSync('Changelog', 'utf-8')
.split('\n')
.shift()
.split(/\s+/)
.pop();
grunt.initConfig({
version: {
options: {
release: version,
pkg: 'package.json'
},
js: {
options: {
prefix: "Version:\\s+"
},
src: ['jquery.iviewer.js']
},
json: {
src: ['package.json', 'iviewer.jquery.json']
}
},
uglify: {
options: {
report: "min",
mangle: false,
banner: 'set me later'
},
js: {
files: {
'jquery.iviewer.min.js': ['jquery.iviewer.js']
}
}
}
});
grunt.loadNpmTasks('grunt-version');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.registerTask('banner', function() {
var banner = fs.readFileSync('jquery.iviewer.js', 'utf-8')
.match(RegExp("^/\\*[^]*?\\*/"))[0] + '\n\n'
grunt.config('uglify.options.banner', banner)
});
grunt.registerTask('changelog', function() {
var date = new Date()
, pad = function(len, symb) {
if (symb.toString().length < len) {
return '0' + symb;
} else {
return symb;
}
}
, stamp = '(' + [
date.getFullYear(),
date.getMonth() + 1,
date.getDate()
].map(pad.bind(null, 2))
.join('/') + ')\n'
, file = grunt.file.read('Changelog')
.replace(/(.*?)\n/, "$1 " + stamp);
grunt.file.write('Changelog', file)
})
grunt.registerTask('release', ['version', 'banner', 'changelog', 'uglify'])
};