Skip to content

Commit

Permalink
Use lazystream for streamFile to avoid fd exhaustion
Browse files Browse the repository at this point in the history
  • Loading branch information
Klowner committed Dec 29, 2015
1 parent 8fc3dd2 commit e044e85
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/src/getContents/streamFile.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,14 @@

var fs = require('graceful-fs');
var stripBom = require('strip-bom-stream');
var lazystream = require('lazystream');

function streamFile(file, opt, cb) {
file.contents = fs.createReadStream(file.path);
var filePath = file.path;

file.contents = new lazystream.Readable(function () {
return fs.createReadStream(filePath);
});

if (opt.stripBOM) {
file.contents = file.contents.pipe(stripBom());
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"graceful-fs": "^4.0.0",
"gulp-sourcemaps": "^1.5.2",
"is-valid-glob": "^0.3.0",
"lazystream": "^1.0.0",
"merge-stream": "^1.0.0",
"mkdirp": "^0.5.0",
"object-assign": "^4.0.0",
Expand Down

0 comments on commit e044e85

Please sign in to comment.