Skip to content

Commit

Permalink
using is-valid-glob module to handle nested arrays properly
Browse files Browse the repository at this point in the history
  • Loading branch information
doowb authored and phated committed Nov 28, 2017
1 parent e5cba5d commit ff01407
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
14 changes: 1 addition & 13 deletions lib/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ var duplexify = require('duplexify');
var merge = require('merge-stream');
var sourcemaps = require('gulp-sourcemaps');
var filterSince = require('vinyl-filter-since');
var isValidGlob = require('is-valid-glob');

var getContents = require('./getContents');
var resolveSymlinks = require('./resolveSymlinks');
Expand Down Expand Up @@ -66,17 +67,4 @@ function src(glob, opt) {
return outputStream;
}

function isValidGlob(glob) {
if (typeof glob === 'string') {
return true;
}
if (!Array.isArray(glob)) {
return false;
}
if (glob.length !== 0) {
return glob.every(isValidGlob);
}
return true;
}

module.exports = src;
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"glob-watcher": "^2.0.0",
"graceful-fs": "^3.0.0",
"gulp-sourcemaps": "^1.5.2",
"is-valid-glob": "^0.1.0",
"merge-stream": "^0.1.7",
"mkdirp": "^0.5.0",
"object-assign": "^2.0.0",
Expand Down
12 changes: 12 additions & 0 deletions test/src.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,18 @@ describe('source stream', function() {
}
});

it('should explode on invalid glob (nested array)', function(done) {
var stream;
try {
stream = vfs.src([['./fixtures/*.coffee']]);
} catch (err) {
should.exist(err);
should.not.exist(stream);
err.message.should.containEql('Invalid glob argument');
done();
}
});

it('should not explode on invalid glob (empty array)', function(done) {
var stream = vfs.src([]);
stream.once('data', done);
Expand Down

0 comments on commit ff01407

Please sign in to comment.