File tree Expand file tree Collapse file tree 5 files changed +32
-8
lines changed
Expand file tree Collapse file tree 5 files changed +32
-8
lines changed Original file line number Diff line number Diff line change 11### HEAD
22
3+ ### 3.0.1 (November XX, 2016)
4+
5+ * Fix: ` undefined ` cli flags don't override config
6+
37### 3.0.0 (October 20, 2016)
48
59* Pin core plugins order:
Original file line number Diff line number Diff line change @@ -110,12 +110,18 @@ function run() {
110110 read ( input , function ( err , buffer ) {
111111 if ( err ) logger . throw ( err ) ;
112112 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 ) ;
119125
120126 if ( program . throwError ) {
121127 assign ( opts , {
Original file line number Diff line number Diff line change @@ -87,11 +87,21 @@ describe('cli', function() {
8787 } ) ;
8888
8989 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 ) {
9191 if ( err ) return done ( err ) ;
9292 var res = util . read ( 'fixtures/cli/output' ) ;
9393 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 ) ;
95105 done ( ) ;
96106 } ) ;
97107 } ) ;
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 11module . exports = {
22 lint : true ,
3+ minify : false ,
34 use : [
45 'postcss-property-lookup'
56 ] ,
You can’t perform that action at this time.
0 commit comments