Skip to content
This repository was archived by the owner on Apr 20, 2018. It is now read-only.

Commit ae0d10f

Browse files
flow add mergeSteps
should fix other problem in #442
1 parent b96d3c7 commit ae0d10f

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

lib/flow.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@ Flow.prototype.setSteps = function (steps) {
3333
this._steps = steps;
3434
};
3535

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+
3642
//
3743
// Returns the postprocessors for the furnished block type
3844
//

test/test-flow.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,4 +98,39 @@ describe('ConfigWriter', function () {
9898
flow.setPost();
9999
assert.deepEqual(flow._post, {});
100100
});
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+
101136
});

0 commit comments

Comments
 (0)