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 1
1
var postcss = require ( 'postcss' ) ;
2
+ var objectAssign = require ( 'object-assign' ) ;
2
3
var path = require ( 'path' ) ;
3
4
var fs = require ( 'fs' ) ;
4
5
@@ -7,14 +8,16 @@ function verifyOptions(options) {
7
8
options = { } ;
8
9
}
9
10
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
+ } ;
16
19
17
- return options ;
20
+ return objectAssign ( { } , defaultOptions , options ) ;
18
21
}
19
22
20
23
function getSortOrderFromOptions ( options ) {
Original file line number Diff line number Diff line change 21
21
" index.js"
22
22
],
23
23
"dependencies" : {
24
+ "object-assign" : " ^4.1.0" ,
24
25
"postcss" : " ^5.1.2"
25
26
},
26
27
"devDependencies" : {
Original file line number Diff line number Diff line change @@ -214,7 +214,11 @@ test('Should sort at-rules by name', t => {
214
214
} ) ;
215
215
216
216
test ( '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' ) ;
218
222
} ) ;
219
223
220
224
test ( '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