File tree 5 files changed +32
-8
lines changed
5 files changed +32
-8
lines changed Original file line number Diff line number Diff line change 1
1
### HEAD
2
2
3
+ ### 3.0.1 (November XX, 2016)
4
+
5
+ * Fix: ` undefined ` cli flags don't override config
6
+
3
7
### 3.0.0 (October 20, 2016)
4
8
5
9
* Pin core plugins order:
Original file line number Diff line number Diff line change @@ -110,12 +110,18 @@ function run() {
110
110
read ( input , function ( err , buffer ) {
111
111
if ( err ) logger . throw ( err ) ;
112
112
var css = buffer . toString ( ) ;
113
- var opts = assign ( { } , config , {
114
- minify : program . minify ,
115
- root : program . importRoot ,
116
- encapsulate : program . encapsulate ,
117
- lint : program . lint
118
- } ) ;
113
+ var flags = [
114
+ 'minify' ,
115
+ 'encapsulate' ,
116
+ 'root' ,
117
+ 'lint'
118
+ ] . reduce ( function ( accumulator , flag ) {
119
+ if ( ( { } ) . hasOwnProperty . call ( program , flag ) ) {
120
+ accumulator [ flag ] = program [ flag ] ;
121
+ }
122
+ return accumulator ;
123
+ } , { } ) ;
124
+ var opts = assign ( { } , config , flags ) ;
119
125
120
126
if ( program . throwError ) {
121
127
assign ( opts , {
Original file line number Diff line number Diff line change @@ -87,11 +87,21 @@ describe('cli', function() {
87
87
} ) ;
88
88
89
89
it ( 'should allow to override config options via cli flags' , function ( done ) {
90
- exec ( 'node bin/suitcss -L -c test/config/test.js test/fixtures/import.css test/fixtures/cli/output.css' , function ( err ) {
90
+ exec ( 'node bin/suitcss -m -c test/config/test.js test/fixtures/import.css test/fixtures/cli/output.css' , function ( err ) {
91
91
if ( err ) return done ( err ) ;
92
92
var res = util . read ( 'fixtures/cli/output' ) ;
93
93
var commentsPattern = / \/ \* [ ^ ] * ?\* \/ / g;
94
- expect ( res ) . to . match ( commentsPattern ) ;
94
+ expect ( res ) . to . not . match ( commentsPattern ) ;
95
+ done ( ) ;
96
+ } ) ;
97
+ } ) ;
98
+
99
+ it ( 'should preserve config options when not passing cli flags' , function ( done ) {
100
+ exec ( 'node bin/suitcss -c test/config/cli-undefined-flags.js test/fixtures/import.css test/fixtures/cli/output.css' , function ( err ) {
101
+ if ( err ) return done ( err ) ;
102
+ var res = util . read ( 'fixtures/cli/output' ) ;
103
+ var commentsPattern = / \/ \* [ ^ ] * ?\* \/ / g;
104
+ expect ( res ) . to . not . match ( commentsPattern ) ;
95
105
done ( ) ;
96
106
} ) ;
97
107
} ) ;
Original file line number Diff line number Diff line change
1
+ module . exports = {
2
+ minify : true
3
+ } ;
Original file line number Diff line number Diff line change 1
1
module . exports = {
2
2
lint : true ,
3
+ minify : false ,
3
4
use : [
4
5
'postcss-property-lookup'
5
6
] ,
You can’t perform that action at this time.
0 commit comments