Skip to content

Commit

Permalink
empty arrays = dead stream, closes #40
Browse files Browse the repository at this point in the history
  • Loading branch information
Contra committed Oct 9, 2014
1 parent 3e3d371 commit 6bba193
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
6 changes: 6 additions & 0 deletions lib/src/index.js
Expand Up @@ -53,6 +53,12 @@ function isValidGlob(glob) {
if (typeof glob === 'string') {
return true;
}
if (Array.isArray(glob) && glob.length !== 0) {
return glob.every(isValidGlob);
}
if (Array.isArray(glob) && glob.length === 0) {
return true;
}
return false;
}

Expand Down
17 changes: 7 additions & 10 deletions test/src.js
Expand Up @@ -26,7 +26,7 @@ describe('source stream', function() {
it('should explode on invalid glob (empty)', function(done) {
var stream;
try {
stream = gulp.src();
stream = vfs.src();
} catch (err) {
should.exist(err);
should.not.exist(stream);
Expand All @@ -37,23 +37,20 @@ describe('source stream', function() {
it('should explode on invalid glob (number)', function(done) {
var stream;
try {
stream = gulp.src(123);
stream = vfs.src(123);
} catch (err) {
should.exist(err);
should.not.exist(stream);
done();
}
});

it('should explode on invalid glob (empty array)', function(done) {
var stream;
try {
stream = gulp.src([]);
} catch (err) {
should.exist(err);
should.not.exist(stream);
it('should not explode on invalid glob (empty array)', function(done) {
var stream = vfs.src([]);
stream.once('data', done);
stream.once('end', function(){
done();
}
});
});

it('should pass through writes', function(done) {
Expand Down

0 comments on commit 6bba193

Please sign in to comment.