Skip to content

Commit 325a784

Browse files
committed
Breaking: Remove passthrough option & infer readable or passthrough
1 parent af035a5 commit 325a784

File tree

4 files changed

+20
-31
lines changed

4 files changed

+20
-31
lines changed

README.md

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -96,14 +96,6 @@ Type: `Boolean`
9696

9797
Default: `true`
9898

99-
##### `options.passthrough`
100-
101-
Allows `.src` to be used in the middle of a pipeline (using a duplex stream) which passes through all objects received and adds all files globbed to the stream.
102-
103-
Type: `Boolean`
104-
105-
Default: `false`
106-
10799
##### `options.sourcemaps`
108100

109101
Enables sourcemap support on files passed through the stream. Will load inline sourcemaps and resolve sourcemap links from files. Uses [gulp-sourcemaps] under the hood.

lib/src/index.js

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,15 @@
11
'use strict';
22

3-
var pumpify = require('pumpify');
4-
var through2 = require('through2');
53
var gs = require('glob-stream');
6-
var duplexify = require('duplexify');
7-
var merge = require('merge-stream');
4+
var pumpify = require('pumpify');
5+
var prepare = require('vinyl-prepare');
6+
var toThrough = require('to-through');
87
var isValidGlob = require('is-valid-glob');
9-
var valueOrFunction = require('value-or-function');
10-
var koalas = require('koalas');
118

12-
var prepare = require('vinyl-prepare');
139
var sourcemap = require('./sourcemap');
1410
var readContents = require('./read-contents');
1511
var resolveSymlinks = require('./resolve-symlinks');
1612

17-
var boolean = valueOrFunction.boolean;
18-
1913
function src(glob, opt) {
2014
if (!opt) {
2115
opt = {};
@@ -25,14 +19,10 @@ function src(glob, opt) {
2519
throw new Error('Invalid glob argument: ' + glob);
2620
}
2721

28-
var passthroughOpt = koalas(boolean(opt.passthrough), false);
29-
3022
// Don't pass `read` option on to through2
3123
opt.readFile = opt.read;
3224
opt.read = undefined;
3325

34-
var inputStream;
35-
3626
var streams = [
3727
gs.create(glob, opt),
3828
resolveSymlinks(opt),
@@ -43,13 +33,7 @@ function src(glob, opt) {
4333

4434
var outputStream = pumpify.obj(streams);
4535

46-
if (passthroughOpt) {
47-
inputStream = through2.obj(opt);
48-
outputStream = merge(outputStream, inputStream);
49-
outputStream = duplexify.obj(inputStream, outputStream);
50-
}
51-
52-
return outputStream;
36+
return toThrough(outputStream);
5337
}
5438

5539

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
"strip-bom-stream": "^1.0.0",
4242
"through2": "^2.0.0",
4343
"through2-filter": "^2.0.0",
44+
"to-through": "^2.0.0",
4445
"value-or-function": "^2.0.0",
4546
"vinyl": "^2.0.0",
4647
"vinyl-prepare": "^0.1.1",

test/src.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ describe('.src()', function() {
105105
], assert);
106106
});
107107

108-
it.skip('passes through writes', function(done) {
108+
it('passes through writes', function(done) {
109109
var file = new File({
110110
base: inputBase,
111111
path: inputPath,
@@ -328,7 +328,7 @@ describe('.src()', function() {
328328
], done);
329329
});
330330

331-
it('passes files through', function(done) {
331+
it('can be used as a through stream and adds new files to the end', function(done) {
332332
var file = new File({
333333
base: inputBase,
334334
path: inputPath,
@@ -343,7 +343,19 @@ describe('.src()', function() {
343343

344344
pipe([
345345
from.obj([file]),
346-
vfs.src(inputPath, { passthrough: true }),
346+
vfs.src(inputPath),
347+
concat(assert),
348+
], done);
349+
});
350+
351+
it('can be used at beginning and in the middle', function(done) {
352+
function assert(files) {
353+
expect(files.length).toEqual(2);
354+
}
355+
356+
pipe([
357+
vfs.src(inputPath),
358+
vfs.src(inputPath),
347359
concat(assert),
348360
], done);
349361
});

0 commit comments

Comments
 (0)