Skip to content

Commit

Permalink
passing options through to readers is still a good idea, so not a ful…
Browse files Browse the repository at this point in the history
…l revert. #72
  • Loading branch information
Contra committed Jun 30, 2015
1 parent f6ead3c commit baf97e1
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 30 deletions.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@ fs.src(['*.js', '!b*.js'])
- read - `true` or `false` if you want the file to be read or not. Useful for stuff like `rm`ing files.
- Default value is `true`
- `false` will disable writing the file to disk via `.dest()`
- stripBOM - `true` or `false` if you want UTF-8 BOM stripped from files as they are read.
- Default value is `true`
- since - `Date` or `number` if you only want files that have been modified since the time specified.
- passthrough - `true` or `false` if you want a duplex stream which passes items through and emits globbed files.
- Default is `false`.
Expand Down
2 changes: 1 addition & 1 deletion lib/src/getContents/bufferFile.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ function bufferFile(file, opt, cb) {
if (err) {
return cb(err);
}
file.contents = opt.stripBOM ? stripBom(data) : data;
file.contents = stripBom(data);
cb(null, file);
});
}
Expand Down
6 changes: 2 additions & 4 deletions lib/src/getContents/streamFile.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@ var fs = require('graceful-fs');
var stripBom = require('strip-bom');

function streamFile(file, opt, cb) {
file.contents = fs.createReadStream(file.path);
if (opt.stripBOM) {
file.contents = file.contents.pipe(stripBom.stream());
}
file.contents = fs.createReadStream(file.path)
.pipe(stripBom.stream());
cb(null, file);
}

Expand Down
1 change: 0 additions & 1 deletion lib/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ function createFile(globFile, enc, cb) {

function src(glob, opt) {
var options = assign({
stripBOM: true,
read: true,
buffer: true,
sourcemaps: false,
Expand Down
22 changes: 0 additions & 22 deletions test/src.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,28 +106,6 @@ describe('source stream', function() {
stream.pipe(bufferStream);
});

it('should not strip BOM from UTF-8-encoded files when stripBOM is false', function(done) {
var expectedPath = path.join(__dirname, './fixtures/bom-utf8.txt');
var expectedContent = fs.readFileSync(expectedPath);

var onEnd = function(){
should.exist(buffered[0].stat);
buffered[0].path.should.equal(expectedPath);
buffered[0].isBuffer().should.equal(true);
buffered[0].contents.length.should.equal(expectedContent.length);
done();
};

var stream = vfs.src('./fixtures/bom-utf8.txt', {
cwd: __dirname,
stripBOM: false
});

var buffered = [];
bufferStream = through.obj(dataWrap(buffered.push.bind(buffered)), onEnd);
stream.pipe(bufferStream);
});

it('should not strip anything that looks like a UTF-8-encoded BOM from UTF-16-BE-encoded files', function(done) {
// Note: this goes for any non-UTF-8 encoding, but testing for UTF-16-BE
// and UTF-16-LE is enough to demonstrate this is done properly.
Expand Down

0 comments on commit baf97e1

Please sign in to comment.