4
4
5
5
module . exports = function ( grunt ) {
6
6
7
+ // Force use of Unix newlines
8
+ grunt . util . linefeed = "\n" ;
9
+
7
10
// Project configuration.
8
11
grunt . initConfig ( {
9
12
// Metadata.
10
13
pkg : grunt . file . readJSON ( "package.json" ) ,
11
- banner : {
12
- compact : "/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - " +
13
- "<%= grunt.template.today('yyyy-mm-dd') %>\n" +
14
- "<%= pkg.homepage ? '* ' + pkg.homepage + '\\n' : '' %>" +
15
- "* Copyright (c) <%= grunt.template.today('yyyy') %> Nicole Sullivan and Nicholas C. Zakas;\n" +
16
- "* Licensed <%= _.pluck(pkg.licenses, 'type').join(', ') %> <%= _.pluck(pkg.licenses, 'url').join(', ') %> */\n" ,
17
- full : "/*!\n" +
18
- "CSSLint\n" +
14
+ banner : "/*!\n" +
15
+ "CSSLint v<%= pkg.version %>\n" +
19
16
"Copyright (c) <%= grunt.template.today('yyyy') %> Nicole Sullivan and Nicholas C. Zakas. All rights reserved.\n" +
20
17
"\n" +
21
18
"Permission is hereby granted, free of charge, to any person obtaining a copy\n" +
@@ -35,10 +32,8 @@ module.exports = function(grunt) {
35
32
"LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n" +
36
33
"OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n" +
37
34
"THE SOFTWARE.\n\n" +
38
- "*/\n" +
39
- "/* Build: v<%= pkg.version %> <%= grunt.template.today('dd-mmmm-yyyy hh:MM:ss') %> */"
40
- } ,
41
- build_dir : "build" ,
35
+ "*/\n" ,
36
+ build_dir : "dist" ,
42
37
//Parser lib copy for versions that can't use requirejs
43
38
parserlib : "node_modules/parserlib/lib/node-parserlib.js" ,
44
39
//clone copy for versions that can't use requirejs
@@ -56,101 +51,91 @@ module.exports = function(grunt) {
56
51
"<%= clone %>" ,
57
52
"<%= csslint_files %>"
58
53
] ,
54
+
59
55
// Task configuration.
60
56
clean : {
61
- build : [ "<%= build_dir %>" ] ,
62
- release : [ "release" ]
57
+ dist : "<%= build_dir %>"
63
58
} ,
59
+
64
60
changelog : {
65
61
dest : "CHANGELOG"
66
62
} ,
63
+
67
64
concat : {
68
65
core : {
69
66
options : {
70
- banner : "<%= banner.full %>\n" +
71
- //Hack for using the node version of parserlib
72
- "var exports = exports || {};\n" +
67
+ banner : "<%= banner %>\n" +
68
+ // Hack for using the node version of parserlib and clone
69
+ "var module = module || {},\n" +
70
+ " exports = exports || {};\n\n" +
73
71
"var CSSLint = (function(){\n" ,
74
72
footer : "\nreturn CSSLint;\n})();"
75
73
} ,
76
74
src : [
77
75
"<%= core_files %>"
78
76
] ,
79
- dest : "<%= build_dir %>/<%= pkg.name %> .js"
77
+ dest : "<%= build_dir %>/csslint .js"
80
78
} , //Build environment workers
81
79
rhino : {
82
80
src : [
83
81
"<%= concat.core.dest %>" ,
84
82
"src/cli/common.js" ,
85
83
"src/cli/rhino.js"
86
84
] ,
87
- dest : "<%= build_dir %>/<%= pkg.name %> -rhino.js"
85
+ dest : "<%= build_dir %>/csslint -rhino.js"
88
86
} ,
89
87
node : {
90
88
options : {
91
- banner : "<%= banner.full %>\n " +
89
+ banner : "<%= banner %>" +
92
90
"var clone = require('clone');\n" +
93
91
"var parserlib = require('parserlib');\n" ,
94
92
footer : "\nexports.CSSLint = CSSLint;"
95
93
} ,
96
94
files : {
97
- "<%= build_dir %>/<%= pkg.name %>-node.js" : [ "<%= csslint_files %>" ] ,
98
- "<%= build_dir %>/npm/lib/<%= pkg.name %>-node.js" : [ "<%= csslint_files %>" ]
95
+ "<%= build_dir %>/csslint-node.js" : [ "<%= csslint_files %>" ]
99
96
}
100
97
} ,
101
98
node_cli : {
102
99
options : {
103
- banner : "#!/usr/bin/env node\n<%= banner.full %>"
100
+ banner : "#!/usr/bin/env node\n<%= banner %>"
104
101
} ,
105
102
src : [
106
103
"src/cli/common.js" ,
107
104
"src/cli/node.js"
108
105
] ,
109
- dest : "<%= build_dir %>/npm/ cli.js"
106
+ dest : "<%= build_dir %>/cli.js"
110
107
} ,
111
108
tests : {
112
109
src : [
113
110
"tests/**/*.js" ,
114
111
"!tests/all-rules.js"
115
112
] ,
116
- dest : "<%= build_dir %>/<%= pkg.name %> -tests.js"
113
+ dest : "<%= build_dir %>/csslint -tests.js"
117
114
} ,
118
115
worker : {
119
116
options : {
120
- banner : "<%= banner.full %>\n " +
117
+ banner : "<%= banner %>" +
121
118
//Hack for using the node version of parserlib
122
119
"var exports = exports || {};\n"
123
120
} ,
124
121
src : [
125
122
"<%= core_files %>" ,
126
123
"src/worker/*.js"
127
124
] ,
128
- dest : "<%= build_dir %>/<%= pkg.name %> -worker.js"
125
+ dest : "<%= build_dir %>/csslint -worker.js"
129
126
} ,
130
127
wsh : {
131
128
src : [
132
129
"<%= concat.core.dest %>" ,
133
130
"src/cli/common.js" ,
134
131
"src/cli/wsh.js"
135
132
] ,
136
- dest : "<%= build_dir %>/<%= pkg.name %>-wsh.js"
137
- }
138
- } ,
139
- copy : {
140
- build : {
141
- expand : true ,
142
- cwd : "<%= build_dir %>/" ,
143
- src : "**/*" ,
144
- dest : "release/"
145
- } ,
146
- npm : {
147
- expand : true ,
148
- src : [ "README.md" , "package.json" ] ,
149
- dest : "release/npm/"
133
+ dest : "<%= build_dir %>/csslint-wsh.js"
150
134
}
151
135
} ,
136
+
152
137
includereplace : {
153
- release : {
138
+ dist : {
154
139
options : {
155
140
// Global variables available in all files
156
141
globals : {
@@ -163,48 +148,55 @@ module.exports = function(grunt) {
163
148
expand : true ,
164
149
cwd : "<%= build_dir %>/" ,
165
150
src : "**/*" ,
166
- dest : "release /"
151
+ dest : "<%= build_dir %> /"
167
152
} ]
168
153
}
169
154
} ,
155
+
170
156
jshint : {
171
157
options : {
172
158
jshintrc : ".jshintrc"
173
159
} ,
174
160
gruntfile : {
175
161
src : [ "Gruntfile.js" , "tasks/*.js" ]
176
162
} ,
163
+ core : {
164
+ src : "src/**/*.js"
165
+ } ,
177
166
demo : {
178
167
src : "demos/*.js"
179
168
} ,
180
- all : {
181
- src : "src/**/*.js"
182
- } ,
183
169
tests : {
170
+ options : {
171
+ jshintrc : "tests/.jshintrc"
172
+ } ,
184
173
src : "tests/**/*.js"
185
174
}
186
175
} ,
176
+
187
177
watch : {
188
178
gruntfile : {
189
179
files : "<%= jshint.gruntfile.src %>" ,
190
- tasks : [ "jshint" ]
180
+ tasks : "jshint"
191
181
} ,
192
182
src : {
193
183
files : "<%= jshint.all.src %>" ,
194
- tasks : [ "jshint:all" ]
184
+ tasks : "jshint:core"
195
185
} ,
196
186
lib_test : {
197
187
files : "<%= jshint.tests.src %>" ,
198
- tasks : [ "jshint:tests" ]
188
+ tasks : "jshint:tests"
199
189
}
200
190
} ,
191
+
201
192
yuitest : {
202
193
tests : {
203
194
src : [
204
195
"tests/**/*.js"
205
196
]
206
197
}
207
198
} ,
199
+
208
200
test_rhino : {
209
201
tests : {
210
202
src : [
@@ -223,14 +215,17 @@ module.exports = function(grunt) {
223
215
grunt . loadTasks ( "tasks" ) ;
224
216
225
217
// Default task.
226
- grunt . registerTask ( "default" , [ "test" ] ) ;
218
+ grunt . registerTask ( "default" , [ "build" , "test" ] ) ;
219
+
220
+ grunt . registerTask ( "build" , [ "clean" , "concat" , "includereplace" ] ) ;
227
221
228
- // Alias for
229
- grunt . registerTask ( "lint" , [ "jshint" ] ) ;
222
+ //Alias for
223
+ grunt . registerTask ( "dist" , "build" ) ;
224
+ grunt . registerTask ( "lint" , "jshint" ) ;
230
225
231
226
// Testing
232
- grunt . registerTask ( "test" , [ "clean: build" , "jshint" , "concat ", "yuitest" ] ) ;
233
- grunt . registerTask ( "rhino" , [ "clean: build" , "jshint" , "concat ", "test_rhino" ] ) ;
227
+ grunt . registerTask ( "test" , [ "build" , "jshint" , "yuitest" ] ) ;
228
+ grunt . registerTask ( "rhino" , [ "build" , "jshint" , "test_rhino" ] ) ;
234
229
235
- grunt . registerTask ( "release" , [ "test" , "clean:release" , "copy" , "includereplace:release ", "changelog" ] ) ;
230
+ grunt . registerTask ( "release" , [ "default " , "changelog" ] ) ;
236
231
} ;
0 commit comments