11#!/usr/bin/env node
22/*! 
33CSSLint 
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. 
55
66Permission 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 
88in the Software without restriction, including without limitation the rights 
99to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 
1010copies 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:
1313The above copyright notice and this permission notice shall be included in 
1414all copies or substantial portions of the Software. 
1515
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 
1717IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
1818FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 
1919AUTHORS 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
2222THE SOFTWARE. 
2323
2424*/ 
25- /* Build: v0.10.0 15-August-2013 01:07:22  */ /* 
25+ /* Build: v0.10.0 11-April-2014 12:11:52  */ /* 
2626 * Encapsulates all of the CLI functionality. The api argument simply 
2727 * provides environment-specific functionality. 
2828 */ 
29- /*global CSSLint*/ 
29+ 
30+ /* exported cli */ 
31+ 
3032function  cli ( api ) { 
3133
3234    var  globalOptions  =  { 
@@ -195,8 +197,8 @@ function cli(api){
195197     */ 
196198    function  outputHelp ( ) { 
197199        var  lenToPad  =  40 , 
198-             toPrint  =  '' , 
199-             formatString  =  '' ; 
200+             toPrint  =  "" , 
201+             formatString  =  "" ; 
200202
201203        api . print ( [ 
202204            "\nUsage: csslint-rhino.js [options]* [file|dir]*" , 
@@ -209,14 +211,14 @@ function cli(api){
209211                // Print the option name and the format if present 
210212                toPrint  +=  "  --"  +  optionName ; 
211213                if  ( globalOptions [ optionName ] . format  !==  "" )  { 
212-                     formatString  =  '='  +  globalOptions [ optionName ] . format ; 
214+                     formatString  =  "="  +  globalOptions [ optionName ] . format ; 
213215                    toPrint  +=  formatString ; 
214216                }  else  { 
215-                     formatString  =  '' ; 
217+                     formatString  =  "" ; 
216218                } 
217219
218220                // 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 ( " " ) ; 
220222
221223                // Print the description 
222224                toPrint  +=  globalOptions [ optionName ] . description  +  "\n" ; 
@@ -306,18 +308,30 @@ function cli(api){
306308    } 
307309
308310    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..." ) ; 
312314                outputHelp ( ) ; 
313315                api . quit ( 0 ) ; 
314316            } 
315317        } 
316318    } 
317319
318320    function  readConfigFile ( options )  { 
319-         var  data  =  api . readFile ( api . getFullPath ( ".csslintrc" ) ) ; 
321+         var  data  =  api . readFile ( api . getFullPath ( ".csslintrc" ) ) , 
322+             json ; 
320323        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+             } 
321335            options  =  processArguments ( data . split ( / [ \s \n \r ] + / m) ,  options ) ; 
322336        } 
323337
@@ -365,12 +379,13 @@ function cli(api){
365379 * CSSLint Node.js Command Line Interface 
366380 */ 
367381
368- /*jshint node:true*/ 
369- /*global cli*/ 
382+ /* jshint node:true */ 
383+ /* global cli */ 
384+ /* exported CSSLint */ 
370385
371386var  fs       =  require ( "fs" ) , 
372387    path     =  require ( "path" ) , 
373-     CSSLint  =  require ( "./lib/ csslint-node" ) . CSSLint ; 
388+     CSSLint  =  require ( "./csslint-node" ) . CSSLint ; 
374389
375390cli ( { 
376391    args : process . argv . slice ( 2 ) , 
0 commit comments