Skip to content

Commit 5fcdf3a

Browse files
committed
Breaking: Remove ability to pass options to through2
1 parent e699278 commit 5fcdf3a

File tree

9 files changed

+39
-50
lines changed

9 files changed

+39
-50
lines changed

README.md

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,6 @@ Default: `false`
123123
##### other
124124

125125
Any glob-related options are documented in [glob-stream] and [node-glob].
126-
Any through2-related options are documented in [through2].
127126
Those options are forwarded verbatim.
128127

129128
### `dest(folder[, options])`
@@ -212,11 +211,6 @@ Type: `Boolean`, `String` or `Object`
212211

213212
Default: `undefined` (do not write sourcemaps)
214213

215-
##### other
216-
217-
Any through2-related options are documented in [through2].
218-
Those options are forwarded verbatim.
219-
220214
### `symlink(folder[, options])`
221215

222216
Takes a folder path string or a function as the first argument and an options object as the second. If given a function, it will be called with each [vinyl] `File` object and must return a folder path.
@@ -264,18 +258,12 @@ Type: `Boolean`
264258

265259
Default: `true` on Windows, `false` on all other platforms
266260

267-
##### other
268-
269-
Any through2-related options are documented in [through2].
270-
Those options are forwarded verbatim.
271-
272261
[glob-stream]: https://github.com/gulpjs/glob-stream
273262
[gulp-sourcemaps]: https://github.com/floridoo/gulp-sourcemaps
274263
[node-glob]: https://github.com/isaacs/node-glob
275264
[gaze]: https://github.com/shama/gaze
276265
[glob-watcher]: https://github.com/wearefractal/glob-watcher
277266
[vinyl]: https://github.com/wearefractal/vinyl
278-
[through2]: https://github.com/rvagg/through2
279267

280268
[downloads-image]: http://img.shields.io/npm/dm/vinyl-fs.svg
281269
[npm-url]: https://www.npmjs.com/package/vinyl-fs

lib/src/index.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,6 @@ function src(glob, opt) {
1919
throw new Error('Invalid glob argument: ' + glob);
2020
}
2121

22-
// Don't pass `read` option on to through2
23-
opt.readFile = opt.read;
24-
opt.read = undefined;
25-
2622
var streams = [
2723
gs(glob, opt),
2824
resolveSymlinks(opt),

lib/src/read-contents/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ function readContents(opt) {
1616
function readFile(file, enc, callback) {
1717

1818
// Skip reading contents if read option says so
19-
if (!koalas(boolean(opt.readFile, file), true)) {
19+
if (!koalas(boolean(opt.read, file), true)) {
2020
return callback(null, file);
2121
}
2222

@@ -45,7 +45,7 @@ function readContents(opt) {
4545
}
4646
}
4747

48-
return through.obj(opt, readFile);
48+
return through.obj(readFile);
4949
}
5050

5151
module.exports = readContents;

lib/src/resolve-symlinks.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ function resolveSymlinks(opt) {
4646
}
4747
}
4848

49-
return through.obj(opt, resolveFile);
49+
return through.obj(resolveFile);
5050
}
5151

5252
module.exports = resolveSymlinks;

lib/symlink/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ function symlink(outFolder, opt) {
7575

7676
var stream = pumpify.obj(
7777
prepare.dest(outFolder, opt),
78-
through.obj(opt, linkFile)
78+
through.obj(linkFile)
7979
);
8080

8181
// Sink the stream to start flowing

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
"to-through": "^2.0.0",
4242
"value-or-function": "^2.0.0",
4343
"vinyl": "^2.0.0",
44-
"vinyl-prepare": "^0.1.1",
44+
"vinyl-prepare": "^0.2.0",
4545
"vinyl-sourcemap": "^0.4.0"
4646
},
4747
"devDependencies": {

test/dest.js

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -806,26 +806,6 @@ describe('.dest()', function() {
806806
});
807807
});
808808

809-
// TODO: need a better way to pass these options through
810-
// Or maybe not at all since we fixed highWaterMark
811-
it('passes options to through2', function(done) {
812-
var file = new File({
813-
base: inputBase,
814-
path: inputPath,
815-
contents: new Buffer(contents),
816-
});
817-
818-
function assert(err) {
819-
expect(err.message).toMatch(/Invalid non-string\/buffer chunk/);
820-
done();
821-
}
822-
823-
pipe([
824-
from.obj([file]),
825-
vfs.dest(outputBase, { objectMode: false }),
826-
], assert);
827-
});
828-
829809
it('successfully processes files with streaming contents', function(done) {
830810
var file = new File({
831811
base: inputBase,
@@ -961,4 +941,26 @@ describe('.dest()', function() {
961941
vfs.dest(outputBase),
962942
], assert);
963943
});
944+
945+
it('does not pass options on to through2', function(done) {
946+
var file = new File({
947+
base: inputBase,
948+
path: inputPath,
949+
contents: null,
950+
});
951+
952+
// Reference: https://github.com/gulpjs/vinyl-fs/issues/153
953+
var read = expect.createSpy().andReturn(false);
954+
955+
function assert() {
956+
// Called never because it's not a valid option
957+
expect(read.calls.length).toEqual(0);
958+
}
959+
960+
pipe([
961+
from.obj([file]),
962+
vfs.dest(outputBase, { read: read }),
963+
concat(assert),
964+
], done);
965+
});
964966
});

test/src.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,11 +360,12 @@ describe('.src()', function() {
360360
], done);
361361
});
362362

363-
it('does not pass options.read on to through2', function(done) {
363+
it('does not pass options on to through2', function(done) {
364364
// Reference: https://github.com/gulpjs/vinyl-fs/issues/153
365365
var read = expect.createSpy().andReturn(false);
366366

367367
function assert() {
368+
// Called once to resolve the option
368369
expect(read.calls.length).toEqual(1);
369370
}
370371

test/symlink.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -731,23 +731,25 @@ describe('symlink stream', function() {
731731
});
732732
});
733733

734-
// TODO: need a better way to pass these options through
735-
// Or maybe not at all since we fixed highWaterMark
736-
it('passes options to through2', function(done) {
734+
it('does not pass options on to through2', function(done) {
737735
var file = new File({
738736
base: inputBase,
739737
path: inputPath,
740738
contents: null,
741739
});
742740

743-
function assert(err) {
744-
expect(err.message).toMatch(/Invalid non-string\/buffer chunk/);
745-
done();
741+
// Reference: https://github.com/gulpjs/vinyl-fs/issues/153
742+
var read = expect.createSpy().andReturn(false);
743+
744+
function assert() {
745+
// Called never because it's not a valid option
746+
expect(read.calls.length).toEqual(0);
746747
}
747748

748749
pipe([
749750
from.obj([file]),
750-
vfs.symlink(outputBase, { objectMode: false }),
751-
], assert);
751+
vfs.symlink(outputBase, { read: read }),
752+
concat(assert),
753+
], done);
752754
});
753755
});

0 commit comments

Comments
 (0)