-
Notifications
You must be signed in to change notification settings - Fork 4
/
Gruntfile.js
160 lines (156 loc) · 4.33 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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
app: {
name: 'Tock.js',
version: '<%= pkg.version %>',
license: '<%= pkg.license %>',
homepage: '<%= pkg.homepage %>',
paths: {
src: 'src',
dist: 'dist'
},
files: {
gruntfile: ['Gruntfile.js'],
js: ['tock.js']
}
},
jshint: {
options: {
camelcase: true,
curly: true,
eqeqeq: true,
jquery: true,
newcap: true,
undef: true,
unused: true,
validthis: true
},
gruntfile: {
options: {
predef: [
'module'
]
},
src: '<%= app.files.gruntfile %>'
},
js: {
options: {
browser: true,
devel: true,
predef: [
'define',
'module',
'require'
]
},
src: '<%= app.paths.src %>/<%= app.files.js %>'
}
},
jscs: {
options: {
'disallowSpacesInNamedFunctionExpression': {
'beforeOpeningRoundBrace': true
},
'disallowSpacesInFunctionExpression': {
'beforeOpeningRoundBrace': true
},
'disallowSpacesInAnonymousFunctionExpression': {
'beforeOpeningRoundBrace': true
},
'disallowSpacesInFunctionDeclaration': {
'beforeOpeningRoundBrace': true
},
'disallowSpaceBeforeBinaryOperators': [
','
],
'requireSpaceBeforeBinaryOperators': true,
'requireSpaceAfterBinaryOperators': true,
'requireCamelCaseOrUpperCaseIdentifiers': true,
'requireCapitalizedConstructors': true,
'disallowMixedSpacesAndTabs': true,
'disallowTrailingWhitespace': true,
'disallowTrailingComma': true,
'disallowSpaceAfterPrefixUnaryOperators': true,
'disallowSpaceBeforePostfixUnaryOperators': true,
'disallowSpacesInsideArrayBrackets': true,
'disallowSpacesInsideParentheses': true,
'requireSpaceAfterKeywords': [
'if',
'else',
'for',
'while',
'do',
'switch',
'case',
'return',
'try',
'catch',
'typeof'
],
'validateIndentation': 2,
'validateLineBreaks': 'LF',
'validateQuoteMarks': true
},
gruntfile: {
options: {
'requireCamelCaseOrUpperCaseIdentifiers': 'ignoreProperties'
},
src: '<%= app.files.gruntfile %>'
},
js: {
src: '<%= app.paths.src %>/<%= app.files.js %>'
}
},
umd: {
js: {
src: '<%= app.paths.src %>/<%= app.files.js %>',
dest: '<%= app.paths.dist %>/<%= app.files.js %>',
amdModuleId: '<%= pkg.name %>', // AMD
objectToExport: '<%= app.name %>', // CommonJS
globalAlias: '<%= app.name %>', // Global
deps: {}
}
},
uglify: {
options: {
banner: '// <%= app.name %> (version <%= app.version %>) <%= app.homepage %>\n// License: <%= app.license %>\n',
compress: {
comparisons: false
}
},
js: {
files: [{
src: '<%= umd.js.dest %>',
ext: '.min.js',
expand: true
}]
}
},
watch: {
gruntfile: {
files: '<%= app.files.gruntfile %>',
tasks: ['check:gruntfile', 'build']
},
js: {
options: {
cwd: '<%= app.paths.src %>'
},
files: '<%= app.files.js %>',
tasks: ['build:js']
}
}
});
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-jscs');
grunt.loadNpmTasks('grunt-notify');
grunt.loadNpmTasks('grunt-umd');
grunt.registerTask('check:gruntfile', ['jshint:gruntfile', 'jscs:gruntfile']);
grunt.registerTask('check:js', ['jshint:js', 'jscs:js']);
grunt.registerTask('check', ['check:gruntfile', 'check:js']);
grunt.registerTask('build:js', ['check:js', 'umd:js', 'uglify:js']);
grunt.registerTask('build', ['build:js']);
grunt.registerTask('default', ['check:gruntfile', 'build']);
};