This repository has been archived by the owner on Jun 21, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
/
Gruntfile.js
115 lines (109 loc) · 2.27 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
module.exports = function(grunt) {
// Requires
require('jit-grunt')(grunt);
var fs=require('fs'),
child_process=require('child_process');
// Get library name
var excludes=['.','..','ender.js','footer.js'],
files=fs.readdirSync('src'),
name,i,j;
if(files.indexOf('header.js')!==-1){
name='header.js';
}
else{
for(i=0,j=files.length;i<j;++i){
if(excludes.indexOf(files[i])==-1){
name=files[i];
break;
}
}
}
// Get version
var version=fs.readFileSync('src/'+name,{encoding:'utf8'}).match(/^\/\*\! \w+ ([0-9.]+)/)[1];
grunt.initConfig({
// Load bower file
bower: grunt.file.readJSON('bower.json'),
// Remove obsolete files
clean: {
old: ['*.min.js']
},
// Lint
jshint: {
library: ['src/*.js'],
options: {
browser : true,
predef : ['W', 'Sheethub', 'define', 'module', 'ActiveXObject', 'console', 'log'],
boss : true,
curly : true,
eqnull : true,
newcap : false,
undef : true,
loopfunc : true,
evil : true,
proto : true,
es3 : true,
}
},
// Minify
uglify: {
options: {
preserveComments: 'some'
},
library: {
files: {
'mediatizr.min.js': ['src/mediatizr.js']
}
}
},
// Concatenate
concat: {
Sheethub: {
src: ['lib/Sheethub*.js', 'mediatizr.min.js'],
dest: 'mediatizr.Sheethub.min.js'
},
W: {
src: ['lib/W*.js', 'mediatizr.min.js'],
dest: 'mediatizr.W.min.js'
},
SheethubW: {
src: ['lib/Sheethub*.js', 'lib/W*.js', 'mediatizr.min.js'],
dest: 'mediatizr.Sheethub.W.min.js'
}
},
// Change library version across files
'string-replace': {
package_json: {
files: {'package.json':'package.json'},
options:{
replacements: [{
pattern: /"version": "[0-9.]+",/,
replacement: '"version": "'+version+'",'
}]
}
},
README_md: {
files: {'README.md':'README.md'},
options:{
replacements: [{
pattern: /^(\w+) [0-9.]+/,
replacement: '$1 '+version
}]
}
}
},
// Publish on package managers
shell: {
options: {
stderr: false
},
npm: {
command: 'npm publish'
},
jam: {
command: 'jam publish'
}
}
});
// Define tasks
grunt.registerTask('default', ['clean:old', 'jshint', 'uglify', 'concat', 'string-replace', 'shell']);
};