This repository was archived by the owner on Apr 20, 2018. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +41
-0
lines changed Expand file tree Collapse file tree 2 files changed +41
-0
lines changed Original file line number Diff line number Diff line change @@ -33,6 +33,12 @@ Flow.prototype.setSteps = function (steps) {
33
33
this . _steps = steps ;
34
34
} ;
35
35
36
+ Flow . prototype . mergeSteps = function ( steps ) {
37
+ // better to use _.defaults than _.merge which merge steps arrays which
38
+ // is not waht is wanted here.
39
+ this . _steps = _ . defaults ( steps || { } , this . _steps ) ;
40
+ } ;
41
+
36
42
//
37
43
// Returns the postprocessors for the furnished block type
38
44
//
Original file line number Diff line number Diff line change @@ -98,4 +98,39 @@ describe('ConfigWriter', function () {
98
98
flow . setPost ( ) ;
99
99
assert . deepEqual ( flow . _post , { } ) ;
100
100
} ) ;
101
+
102
+ it ( 'should be able to merge steps' , function ( ) {
103
+ // default flow
104
+ var flow = new Flow ( {
105
+ steps : {
106
+ js : [ 'concat' , 'uglify' ] ,
107
+ css : [ 'concat' , 'cssmin' ]
108
+ } ,
109
+ post : { }
110
+ } ) ;
111
+ // this might be called if someone define a flow without adding a `post` entry
112
+ flow . mergeSteps ( {
113
+ js : [ 'foo' , 'bar' ]
114
+ } ) ;
115
+ assert . deepEqual ( flow . steps ( 'js' ) , [ 'foo' , 'bar' ] ) ;
116
+ assert . deepEqual ( flow . steps ( 'css' ) , [ 'concat' , 'cssmin' ] ) ;
117
+ } ) ;
118
+
119
+ it ( 'should be able to merge steps' , function ( ) {
120
+ // default flow
121
+ var flow = new Flow ( {
122
+ steps : {
123
+ js : [ 'concat' , 'uglify' ] ,
124
+ css : [ 'concat' , 'cssmin' ]
125
+ } ,
126
+ post : { }
127
+ } ) ;
128
+ // this might be called if someone define a flow without adding a `post` entry
129
+ flow . mergeSteps ( {
130
+ js : [ 'uglify' ]
131
+ } ) ;
132
+ assert . deepEqual ( flow . steps ( 'js' ) , [ 'uglify' ] ) ;
133
+ assert . deepEqual ( flow . steps ( 'css' ) , [ 'concat' , 'cssmin' ] ) ;
134
+ } ) ;
135
+
101
136
} ) ;
You can’t perform that action at this time.
0 commit comments