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);
63
63
* Settings.
64
64
*/
65
65
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
+
66
73
var input = program . args [ 0 ] ? resolve ( program . args [ 0 ] ) : null ;
67
74
var 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 ) : { } ;
69
76
var verbose = program . verbose ;
70
77
var regen = program . watch && input && output ;
71
78
Original file line number Diff line number Diff line change @@ -76,7 +76,7 @@ describe('cli', function() {
76
76
} ) ;
77
77
} ) ;
78
78
79
- it ( 'should allow a config file to be passed' , function ( done ) {
79
+ it ( 'should allow a config module to be passed' , function ( done ) {
80
80
exec ( 'node bin/suitcss -i test/fixtures -c test/config/test.js test/fixtures/config.css test/fixtures/cli/output.css' , function ( err ) {
81
81
if ( err ) return done ( err ) ;
82
82
var res = util . read ( 'fixtures/cli/output' ) ;
@@ -86,6 +86,16 @@ describe('cli', function() {
86
86
} ) ;
87
87
} ) ;
88
88
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
+
89
99
it ( 'should allow to override config options via cli flags' , function ( done ) {
90
100
exec ( 'node bin/suitcss -m -c test/config/test.js test/fixtures/import.css test/fixtures/cli/output.css' , function ( err ) {
91
101
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