forked from CSSLint/csslint
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
231 lines (212 loc) · 7.66 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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
/* jshint camelcase:false, node:true */
"use strict";
module.exports = function(grunt) {
// Force use of Unix newlines
grunt.util.linefeed = "\n";
// Project configuration.
grunt.initConfig({
// Metadata.
pkg: grunt.file.readJSON("package.json"),
banner: "/*!\n" +
"CSSLint v<%= pkg.version %>\n" +
"Copyright (c) <%= grunt.template.today('yyyy') %> Nicole Sullivan and Nicholas C. Zakas. All rights reserved.\n" +
"\n" +
"Permission is hereby granted, free of charge, to any person obtaining a copy\n" +
"of this software and associated documentation files (the 'Software'), to deal\n" +
"in the Software without restriction, including without limitation the rights\n" +
"to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n" +
"copies of the Software, and to permit persons to whom the Software is\n" +
"furnished to do so, subject to the following conditions:\n" +
"\n" +
"The above copyright notice and this permission notice shall be included in\n" +
"all copies or substantial portions of the Software.\n" +
"\n" +
"THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n" +
"IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n" +
"FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n" +
"AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n" +
"LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n" +
"OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n" +
"THE SOFTWARE.\n\n" +
"*/\n",
build_dir: "dist",
//Parser lib copy for versions that can't use requirejs
parserlib: "node_modules/parserlib/lib/node-parserlib.js",
//clone copy for versions that can't use requirejs
clone: "node_modules/clone/clone.js",
//Core CSSLint files used by most versions
csslint_files: [
"src/core/CSSLint.js",
"src/core/*.js",
"src/rules/*.js",
"src/formatters/*.js"
],
//Core fileset used by most versions
core_files: [
"<%= parserlib %>",
"<%= clone %>",
"<%= csslint_files %>"
],
// Task configuration.
clean: {
dist: "<%= build_dir %>"
},
changelog: {
dest: "CHANGELOG"
},
concat: {
core: {
options: {
banner: "<%= banner %>\n" +
// Hack for using the node version of parserlib and clone
"var module = module || {},\n" +
" exports = exports || {};\n\n" +
"var CSSLint = (function(){\n",
footer: "\nreturn CSSLint;\n})();"
},
src: [
"<%= core_files %>"
],
dest: "<%= build_dir %>/csslint.js"
},//Build environment workers
rhino: {
src: [
"<%= concat.core.dest %>",
"src/cli/common.js",
"src/cli/rhino.js"
],
dest: "<%= build_dir %>/csslint-rhino.js"
},
node: {
options: {
banner: "<%= banner %>" +
"var clone = require('clone');\n" +
"var parserlib = require('parserlib');\n",
footer: "\nexports.CSSLint = CSSLint;"
},
files: {
"<%= build_dir %>/csslint-node.js": ["<%= csslint_files %>"]
}
},
node_cli: {
options: {
banner: "#!/usr/bin/env node\n<%= banner %>"
},
src: [
"src/cli/common.js",
"src/cli/node.js"
],
dest: "<%= build_dir %>/cli.js"
},
tests: {
src: [
"tests/**/*.js",
"!tests/all-rules.js"
],
dest: "<%= build_dir %>/csslint-tests.js"
},
worker: {
options: {
banner: "<%= banner %>" +
//Hack for using the node version of parserlib
"var exports = exports || {};\n"
},
src: [
"<%= core_files %>",
"src/worker/*.js"
],
dest: "<%= build_dir %>/csslint-worker.js"
},
wsh: {
src: [
"<%= concat.core.dest %>",
"src/cli/common.js",
"src/cli/wsh.js"
],
dest: "<%= build_dir %>/csslint-wsh.js"
}
},
includereplace: {
dist: {
options: {
// Global variables available in all files
globals: {
VERSION: "<%= pkg.version %>"
},
prefix: "@",
suffix: "@"
},
files: [{
expand: true,
cwd: "<%= build_dir %>/",
src: "**/*",
dest: "<%= build_dir %>/"
}]
}
},
jshint: {
options: {
jshintrc: ".jshintrc"
},
gruntfile: {
src: ["Gruntfile.js", "tasks/*.js"]
},
core: {
src: "src/**/*.js"
},
demo: {
src: "demos/*.js"
},
tests: {
options: {
jshintrc: "tests/.jshintrc"
},
src: "tests/**/*.js"
}
},
watch: {
gruntfile: {
files: "<%= jshint.gruntfile.src %>",
tasks: "jshint"
},
src: {
files: "<%= jshint.all.src %>",
tasks: "jshint:core"
},
lib_test: {
files: "<%= jshint.tests.src %>",
tasks: "jshint:tests"
}
},
yuitest: {
tests: {
src: [
["tests/**/*.js", "!tests/testrunner.js"]
]
}
},
test_rhino: {
tests: {
src: [
"<%= concat.tests.dest %>",
"tests/all-rules.js"
]
}
}
});
// Load any grunt plugins found in package.json.
require("load-grunt-tasks")(grunt, {scope: "devDependencies"});
require("time-grunt")(grunt);
// Load custom tasks
grunt.loadTasks("tasks");
// Default task.
grunt.registerTask("default", ["build", "test"]);
grunt.registerTask("build", ["clean", "concat", "includereplace"]);
//Alias for
grunt.registerTask("dist", "build");
grunt.registerTask("lint", "jshint");
// Testing
grunt.registerTask("test", ["build", "jshint", "yuitest"]);
grunt.registerTask("rhino", ["build", "jshint", "test_rhino"]);
grunt.registerTask("release", ["default", "changelog"]);
};