File tree Expand file tree Collapse file tree 3 files changed +16
-8
lines changed Expand file tree Collapse file tree 3 files changed +16
-8
lines changed Original file line number Diff line number Diff line change 11var postcss = require ( 'postcss' ) ;
2+ var objectAssign = require ( 'object-assign' ) ;
23var path = require ( 'path' ) ;
34var fs = require ( 'fs' ) ;
45
@@ -7,14 +8,16 @@ function verifyOptions(options) {
78 options = { } ;
89 }
910
10- options [ 'sort-order' ] = options [ 'sort-order' ] || 'default' ;
11- options [ 'empty-lines-between-children-rules' ] = options [ 'empty-lines-between-children-rules' ] || 0 ;
12- options [ 'empty-lines-between-media-rules' ] = options [ 'empty-lines-between-media-rules' ] || 0 ;
13- options [ 'preserve-empty-lines-between-children-rules' ] = options [ 'preserve-empty-lines-between-children-rules' ] || false ;
14- options [ 'empty-lines-before-comment' ] = options [ 'empty-lines-before-comment' ] || 0 ;
15- options [ 'empty-lines-after-comment' ] = options [ 'empty-lines-after-comment' ] || 0 ;
11+ var defaultOptions = {
12+ 'sort-order' : 'default' ,
13+ 'empty-lines-between-children-rules' : 0 ,
14+ 'empty-lines-between-media-rules' : 0 ,
15+ 'preserve-empty-lines-between-children-rules' : false ,
16+ 'empty-lines-before-comment' : 0 ,
17+ 'empty-lines-after-comment' : 0 ,
18+ } ;
1619
17- return options ;
20+ return objectAssign ( { } , defaultOptions , options ) ;
1821}
1922
2023function getSortOrderFromOptions ( options ) {
Original file line number Diff line number Diff line change 2121 " index.js"
2222 ],
2323 "dependencies" : {
24+ "object-assign" : " ^4.1.0" ,
2425 "postcss" : " ^5.1.2"
2526 },
2627 "devDependencies" : {
Original file line number Diff line number Diff line change @@ -214,7 +214,11 @@ test('Should sort at-rules by name', t => {
214214} ) ;
215215
216216test ( 'Should use default config if config is empty' , t => {
217- return run ( t , 'without-specified-config' ) ;
217+ return run ( t , 'without-specified-config' , null ) ;
218+ } ) ;
219+
220+ test ( 'Should use default config if config isn\'t an object' , t => {
221+ return run ( t , 'without-specified-config' , 'config' ) ;
218222} ) ;
219223
220224test ( 'Should sort prefixed propertyes as unprefixed if first one not in order, but second one in' , t => {
You can’t perform that action at this time.
0 commit comments