File tree Expand file tree Collapse file tree 3 files changed +30
-2
lines changed
Expand file tree Collapse file tree 3 files changed +30
-2
lines changed Original file line number Diff line number Diff line change @@ -63,9 +63,16 @@ program.parse(process.argv);
6363 * Settings.
6464 */
6565
66+ function requireOrParse ( configFile ) {
67+ var configPath = resolve ( configFile ) ;
68+ var ext = path . extname ( configPath ) ;
69+ var readFn = / j s | j s o n / . test ( ext ) ? require : fs . readJsonSync ;
70+ return readFn ( configPath ) ;
71+ }
72+
6673var input = program . args [ 0 ] ? resolve ( program . args [ 0 ] ) : null ;
6774var output = program . args [ 1 ] ? resolve ( program . args [ 1 ] ) : null ;
68- var config = program . config ? require ( resolve ( program . config ) ) : null ;
75+ var config = program . config ? requireOrParse ( program . config ) : { } ;
6976var verbose = program . verbose ;
7077var regen = program . watch && input && output ;
7178
Original file line number Diff line number Diff line change @@ -76,7 +76,7 @@ describe('cli', function() {
7676 } ) ;
7777 } ) ;
7878
79- it ( 'should allow a config file to be passed' , function ( done ) {
79+ it ( 'should allow a config module to be passed' , function ( done ) {
8080 exec ( 'node bin/suitcss -i test/fixtures -c test/config/test.js test/fixtures/config.css test/fixtures/cli/output.css' , function ( err ) {
8181 if ( err ) return done ( err ) ;
8282 var res = util . read ( 'fixtures/cli/output' ) ;
@@ -86,6 +86,16 @@ describe('cli', function() {
8686 } ) ;
8787 } ) ;
8888
89+ it ( 'should allow an arbitrarily named json config file to be passed' , function ( done ) {
90+ exec ( 'node bin/suitcss -i test/fixtures -c test/config/test.config test/fixtures/config.css test/fixtures/cli/output.css' , function ( err ) {
91+ if ( err ) return done ( err ) ;
92+ var res = util . read ( 'fixtures/cli/output' ) ;
93+ var expected = util . read ( 'fixtures/config.out' ) ;
94+ expect ( res ) . to . equal ( expected ) ;
95+ done ( ) ;
96+ } ) ;
97+ } ) ;
98+
8999 it ( 'should allow to override config options via cli flags' , function ( done ) {
90100 exec ( 'node bin/suitcss -m -c test/config/test.js test/fixtures/import.css test/fixtures/cli/output.css' , function ( err ) {
91101 if ( err ) return done ( err ) ;
Original file line number Diff line number Diff line change 1+ {
2+ "lint": true,
3+ "minify": false,
4+ "use": [
5+ "postcss-property-lookup"
6+ ],
7+ "autoprefixer": {
8+ "add": false,
9+ "remove": false
10+ }
11+ }
You can’t perform that action at this time.
0 commit comments