Skip to content

Commit

Permalink
Breaking: Remove ability to pass options to through2
Browse files Browse the repository at this point in the history
  • Loading branch information
phated committed Nov 30, 2017
1 parent e699278 commit 5fcdf3a
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 50 deletions.
12 changes: 0 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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])`
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down
4 changes: 0 additions & 4 deletions lib/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
4 changes: 2 additions & 2 deletions lib/src/read-contents/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -45,7 +45,7 @@ function readContents(opt) {
}
}

return through.obj(opt, readFile);
return through.obj(readFile);
}

module.exports = readContents;
2 changes: 1 addition & 1 deletion lib/src/resolve-symlinks.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ function resolveSymlinks(opt) {
}
}

return through.obj(opt, resolveFile);
return through.obj(resolveFile);
}

module.exports = resolveSymlinks;
2 changes: 1 addition & 1 deletion lib/symlink/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
42 changes: 22 additions & 20 deletions test/dest.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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);
});
});
3 changes: 2 additions & 1 deletion test/src.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
18 changes: 10 additions & 8 deletions test/symlink.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});

0 comments on commit 5fcdf3a

Please sign in to comment.