diff --git a/README.md b/README.md index bb2802d4..f675bf4b 100644 --- a/README.md +++ b/README.md @@ -123,7 +123,6 @@ Default: `false` ##### other Any glob-related options are documented in [glob-stream] and [node-glob]. -Any through2-related options are documented in [through2]. Those options are forwarded verbatim. ### `dest(folder[, options])` @@ -212,11 +211,6 @@ Type: `Boolean`, `String` or `Object` Default: `undefined` (do not write sourcemaps) -##### other - -Any through2-related options are documented in [through2]. -Those options are forwarded verbatim. - ### `symlink(folder[, options])` 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` Default: `true` on Windows, `false` on all other platforms -##### other - -Any through2-related options are documented in [through2]. -Those options are forwarded verbatim. - [glob-stream]: https://github.com/gulpjs/glob-stream [gulp-sourcemaps]: https://github.com/floridoo/gulp-sourcemaps [node-glob]: https://github.com/isaacs/node-glob [gaze]: https://github.com/shama/gaze [glob-watcher]: https://github.com/wearefractal/glob-watcher [vinyl]: https://github.com/wearefractal/vinyl -[through2]: https://github.com/rvagg/through2 [downloads-image]: http://img.shields.io/npm/dm/vinyl-fs.svg [npm-url]: https://www.npmjs.com/package/vinyl-fs diff --git a/lib/src/index.js b/lib/src/index.js index 431b68ee..97205ae5 100644 --- a/lib/src/index.js +++ b/lib/src/index.js @@ -19,10 +19,6 @@ function src(glob, opt) { throw new Error('Invalid glob argument: ' + glob); } - // Don't pass `read` option on to through2 - opt.readFile = opt.read; - opt.read = undefined; - var streams = [ gs(glob, opt), resolveSymlinks(opt), diff --git a/lib/src/read-contents/index.js b/lib/src/read-contents/index.js index eceb37ea..2a75b1cd 100644 --- a/lib/src/read-contents/index.js +++ b/lib/src/read-contents/index.js @@ -16,7 +16,7 @@ function readContents(opt) { function readFile(file, enc, callback) { // Skip reading contents if read option says so - if (!koalas(boolean(opt.readFile, file), true)) { + if (!koalas(boolean(opt.read, file), true)) { return callback(null, file); } @@ -45,7 +45,7 @@ function readContents(opt) { } } - return through.obj(opt, readFile); + return through.obj(readFile); } module.exports = readContents; diff --git a/lib/src/resolve-symlinks.js b/lib/src/resolve-symlinks.js index 55856385..03fd7d79 100644 --- a/lib/src/resolve-symlinks.js +++ b/lib/src/resolve-symlinks.js @@ -46,7 +46,7 @@ function resolveSymlinks(opt) { } } - return through.obj(opt, resolveFile); + return through.obj(resolveFile); } module.exports = resolveSymlinks; diff --git a/lib/symlink/index.js b/lib/symlink/index.js index 66721a1d..0a1bf769 100644 --- a/lib/symlink/index.js +++ b/lib/symlink/index.js @@ -75,7 +75,7 @@ function symlink(outFolder, opt) { var stream = pumpify.obj( prepare.dest(outFolder, opt), - through.obj(opt, linkFile) + through.obj(linkFile) ); // Sink the stream to start flowing diff --git a/package.json b/package.json index 89c4ae65..ed5a2707 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "to-through": "^2.0.0", "value-or-function": "^2.0.0", "vinyl": "^2.0.0", - "vinyl-prepare": "^0.1.1", + "vinyl-prepare": "^0.2.0", "vinyl-sourcemap": "^0.4.0" }, "devDependencies": { diff --git a/test/dest.js b/test/dest.js index 04ce4f04..44516db4 100644 --- a/test/dest.js +++ b/test/dest.js @@ -806,26 +806,6 @@ describe('.dest()', function() { }); }); - // TODO: need a better way to pass these options through - // Or maybe not at all since we fixed highWaterMark - it('passes options to through2', function(done) { - var file = new File({ - base: inputBase, - path: inputPath, - contents: new Buffer(contents), - }); - - function assert(err) { - expect(err.message).toMatch(/Invalid non-string\/buffer chunk/); - done(); - } - - pipe([ - from.obj([file]), - vfs.dest(outputBase, { objectMode: false }), - ], assert); - }); - it('successfully processes files with streaming contents', function(done) { var file = new File({ base: inputBase, @@ -961,4 +941,26 @@ describe('.dest()', function() { vfs.dest(outputBase), ], assert); }); + + it('does not pass options on to through2', function(done) { + var file = new File({ + base: inputBase, + path: inputPath, + contents: null, + }); + + // Reference: https://github.com/gulpjs/vinyl-fs/issues/153 + var read = expect.createSpy().andReturn(false); + + function assert() { + // Called never because it's not a valid option + expect(read.calls.length).toEqual(0); + } + + pipe([ + from.obj([file]), + vfs.dest(outputBase, { read: read }), + concat(assert), + ], done); + }); }); diff --git a/test/src.js b/test/src.js index ce911272..f7fba846 100644 --- a/test/src.js +++ b/test/src.js @@ -360,11 +360,12 @@ describe('.src()', function() { ], done); }); - it('does not pass options.read on to through2', function(done) { + it('does not pass options on to through2', function(done) { // Reference: https://github.com/gulpjs/vinyl-fs/issues/153 var read = expect.createSpy().andReturn(false); function assert() { + // Called once to resolve the option expect(read.calls.length).toEqual(1); } diff --git a/test/symlink.js b/test/symlink.js index 9c0dcb6b..021fbf97 100644 --- a/test/symlink.js +++ b/test/symlink.js @@ -731,23 +731,25 @@ describe('symlink stream', function() { }); }); - // TODO: need a better way to pass these options through - // Or maybe not at all since we fixed highWaterMark - it('passes options to through2', function(done) { + it('does not pass options on to through2', function(done) { var file = new File({ base: inputBase, path: inputPath, contents: null, }); - function assert(err) { - expect(err.message).toMatch(/Invalid non-string\/buffer chunk/); - done(); + // Reference: https://github.com/gulpjs/vinyl-fs/issues/153 + var read = expect.createSpy().andReturn(false); + + function assert() { + // Called never because it's not a valid option + expect(read.calls.length).toEqual(0); } pipe([ from.obj([file]), - vfs.symlink(outputBase, { objectMode: false }), - ], assert); + vfs.symlink(outputBase, { read: read }), + concat(assert), + ], done); }); });