1 | 'use strict';
|
2 |
|
3 | var match = require('gulp-match');
|
4 | var ternaryStream = require('ternary-stream');
|
5 | var through2 = require('through2');
|
6 |
|
7 | module.exports = function (condition, trueChild, falseChild, minimatchOptions) {
|
8 | if (!trueChild) {
|
9 | throw new Error('gulp-if: child action is required');
|
10 | }
|
11 |
|
12 | if (typeof condition === 'boolean') {
|
13 |
|
14 |
|
15 | return condition ? trueChild : (falseChild || through2.obj());
|
16 | }
|
17 |
|
18 | function classifier (file) {
|
19 | return !!match(file, condition, minimatchOptions);
|
20 | }
|
21 |
|
22 | return ternaryStream(classifier, trueChild, falseChild);
|
23 | };
|