1
1
#!/usr/bin/env node
2
2
/*!
3
3
CSSLint
4
- Copyright (c) 2013 Nicole Sullivan and Nicholas C. Zakas. All rights reserved.
4
+ Copyright (c) 2014 Nicole Sullivan and Nicholas C. Zakas. All rights reserved.
5
5
6
6
Permission is hereby granted, free of charge, to any person obtaining a copy
7
- of this software and associated documentation files (the " Software" ), to deal
7
+ of this software and associated documentation files (the ' Software' ), to deal
8
8
in the Software without restriction, including without limitation the rights
9
9
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
10
copies of the Software, and to permit persons to whom the Software is
@@ -13,7 +13,7 @@ furnished to do so, subject to the following conditions:
13
13
The above copyright notice and this permission notice shall be included in
14
14
all copies or substantial portions of the Software.
15
15
16
- THE SOFTWARE IS PROVIDED " AS IS" , WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ THE SOFTWARE IS PROVIDED ' AS IS' , WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
17
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
18
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
19
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
@@ -22,11 +22,13 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
22
THE SOFTWARE.
23
23
24
24
*/
25
- /* Build: v0.10.0 15-August-2013 01:07:22 */ /*
25
+ /* Build: v0.10.0 11-April-2014 12:11:52 */ /*
26
26
* Encapsulates all of the CLI functionality. The api argument simply
27
27
* provides environment-specific functionality.
28
28
*/
29
- /*global CSSLint*/
29
+
30
+ /* exported cli */
31
+
30
32
function cli ( api ) {
31
33
32
34
var globalOptions = {
@@ -195,8 +197,8 @@ function cli(api){
195
197
*/
196
198
function outputHelp ( ) {
197
199
var lenToPad = 40 ,
198
- toPrint = '' ,
199
- formatString = '' ;
200
+ toPrint = "" ,
201
+ formatString = "" ;
200
202
201
203
api . print ( [
202
204
"\nUsage: csslint-rhino.js [options]* [file|dir]*" ,
@@ -209,14 +211,14 @@ function cli(api){
209
211
// Print the option name and the format if present
210
212
toPrint += " --" + optionName ;
211
213
if ( globalOptions [ optionName ] . format !== "" ) {
212
- formatString = '=' + globalOptions [ optionName ] . format ;
214
+ formatString = "=" + globalOptions [ optionName ] . format ;
213
215
toPrint += formatString ;
214
216
} else {
215
- formatString = '' ;
217
+ formatString = "" ;
216
218
}
217
219
218
220
// Pad out with the appropriate number of spaces
219
- toPrint += new Array ( lenToPad - ( optionName . length + formatString . length ) ) . join ( ' ' ) ;
221
+ toPrint += new Array ( lenToPad - ( optionName . length + formatString . length ) ) . join ( " " ) ;
220
222
221
223
// Print the description
222
224
toPrint += globalOptions [ optionName ] . description + "\n" ;
@@ -306,18 +308,30 @@ function cli(api){
306
308
}
307
309
308
310
function validateOptions ( options ) {
309
- for ( var option_key in options ) {
310
- if ( ! globalOptions . hasOwnProperty ( option_key ) && option_key !== ' files' ) {
311
- api . print ( option_key + ' is not a valid option. Exiting...' ) ;
311
+ for ( var optionKey in options ) {
312
+ if ( ! globalOptions . hasOwnProperty ( optionKey ) && optionKey !== " files" ) {
313
+ api . print ( optionKey + " is not a valid option. Exiting..." ) ;
312
314
outputHelp ( ) ;
313
315
api . quit ( 0 ) ;
314
316
}
315
317
}
316
318
}
317
319
318
320
function readConfigFile ( options ) {
319
- var data = api . readFile ( api . getFullPath ( ".csslintrc" ) ) ;
321
+ var data = api . readFile ( api . getFullPath ( ".csslintrc" ) ) ,
322
+ json ;
320
323
if ( data ) {
324
+ if ( data . charAt ( 0 ) === "{" ) {
325
+ try {
326
+ json = JSON . parse ( data ) ;
327
+ data = "" ;
328
+ for ( var optionName in json ) {
329
+ if ( json . hasOwnProperty ( optionName ) ) {
330
+ data += "--" + optionName + "=" + json [ optionName ] . join ( ) ;
331
+ }
332
+ }
333
+ } catch ( e ) { }
334
+ }
321
335
options = processArguments ( data . split ( / [ \s \n \r ] + / m) , options ) ;
322
336
}
323
337
@@ -365,12 +379,13 @@ function cli(api){
365
379
* CSSLint Node.js Command Line Interface
366
380
*/
367
381
368
- /*jshint node:true*/
369
- /*global cli*/
382
+ /* jshint node:true */
383
+ /* global cli */
384
+ /* exported CSSLint */
370
385
371
386
var fs = require ( "fs" ) ,
372
387
path = require ( "path" ) ,
373
- CSSLint = require ( "./lib/ csslint-node" ) . CSSLint ;
388
+ CSSLint = require ( "./csslint-node" ) . CSSLint ;
374
389
375
390
cli ( {
376
391
args : process . argv . slice ( 2 ) ,
0 commit comments