From 8e72117c82faf590fe6f838997ea29e75f95efcd Mon Sep 17 00:00:00 2001 From: Blaine Bublitz Date: Sun, 11 Jun 2023 14:34:08 -0700 Subject: [PATCH] fix: Correct regression with src using arrays of globs --- lib/src/index.js | 10 +++++++++- test/src.js | 10 ++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/lib/src/index.js b/lib/src/index.js index 99d2cda6..278f3f70 100644 --- a/lib/src/index.js +++ b/lib/src/index.js @@ -14,6 +14,10 @@ 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); @@ -21,7 +25,11 @@ function src(glob, opt) { 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), diff --git a/test/src.js b/test/src.js index eec726d8..9ea2f7cb 100644 --- a/test/src.js +++ b/test/src.js @@ -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());