Skip to content

Commit bd30cfb

Browse files
authored
Minor tweak (#226)
1 parent 9a2209c commit bd30cfb

3 files changed

Lines changed: 8 additions & 3 deletions

File tree

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {isGitIgnored, isGitIgnoredSync} from './gitignore.js';
66
import {FilterStream, toPath, isNegativePattern} from './utilities.js';
77

88
const assertPatternsInput = patterns => {
9-
if (!patterns.every(pattern => typeof pattern === 'string')) {
9+
if (patterns.some(pattern => typeof pattern !== 'string')) {
1010
throw new TypeError('Patterns must be a string or an array of strings');
1111
}
1212
};

tests/globby.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,10 @@ test('glob - multiple file paths', async t => {
9191
t.deepEqual(await runGlobby(t, ['a.tmp', 'b.tmp']), ['a.tmp', 'b.tmp']);
9292
});
9393

94+
test('glob - empty patterns', async t => {
95+
t.deepEqual(await runGlobby(t, []), []);
96+
});
97+
9498
test('glob with multiple patterns', async t => {
9599
t.deepEqual(await runGlobby(t, ['a.tmp', '*.tmp', '!{c,d,e}.tmp']), ['a.tmp', 'b.tmp']);
96100
});
@@ -112,14 +116,14 @@ test('glob - stream async iterator support', async t => {
112116
t.deepEqual(results, ['a.tmp', 'b.tmp', 'c.tmp', 'd.tmp', 'e.tmp']);
113117
});
114118

115-
test.serial('cwd option - sync', async t => {
119+
test.serial('cwd option', async t => {
116120
process.chdir(temporary);
117121
t.deepEqual(await runGlobby(t, '*.tmp', {cwd}), ['a.tmp', 'b.tmp', 'c.tmp', 'd.tmp', 'e.tmp']);
118122
t.deepEqual(await runGlobby(t, ['a.tmp', '*.tmp', '!{c,d,e}.tmp'], {cwd}), ['a.tmp', 'b.tmp']);
119123
process.chdir(cwd);
120124
});
121125

122-
test('don\'t mutate the options object - async', async t => {
126+
test('don\'t mutate the options object', async t => {
123127
await runGlobby(t, ['*.tmp', '!b.tmp'], Object.freeze({ignore: Object.freeze([])}));
124128
t.pass();
125129
});

tests/utilities.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export const invalidPatterns = [
2121
[5],
2222
function () {},
2323
[function () {}],
24+
[['string']],
2425
];
2526

2627
export const isUnique = array => new Set(array).size === array.length;

0 commit comments

Comments
 (0)