Skip to content

Commit

Permalink
fix: Correct regression with src using arrays of globs (#342)
Browse files Browse the repository at this point in the history
  • Loading branch information
phated committed Jun 11, 2023
1 parent 9ba20fd commit 5659934
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/src/index.js
Expand Up @@ -14,14 +14,22 @@ var sourcemap = require('./sourcemap');
var readContents = require('./read-contents');
var resolveSymlinks = require('./resolve-symlinks');

function normalize(glob) {
return normalizePath(glob, false);
}

function src(glob, opt) {
var optResolver = createResolver(config, opt);

if (!isValidGlob(glob)) {
throw new Error('Invalid glob argument: ' + glob);
}

glob = normalizePath(glob, false);
if (!Array.isArray(glob)) {
glob = [glob];
}

glob = glob.map(normalize);

var outputStream = pipeline(
gs(glob, opt),
Expand Down
10 changes: 10 additions & 0 deletions test/src.js
Expand Up @@ -110,6 +110,16 @@ describeStreams('.src()', function (stream) {
}
});

it('supports arrays of globs', function (done) {
var cwd = path.relative(process.cwd(), __dirname);

var stream = vfs.src(['./fixtures/test.txt', './fixtures/bom-*.txt'], {
cwd: cwd,
});
expect(stream).toEqual(expect.anything());
done();
});

it('emits an error on file not existing', function (done) {
function assert(err) {
expect(err).toEqual(expect.anything());
Expand Down

0 comments on commit 5659934

Please sign in to comment.