Skip to content

Commit

Permalink
Minor tweak (#226)
Browse files Browse the repository at this point in the history
  • Loading branch information
fisker committed Jan 25, 2022
1 parent 9a2209c commit bd30cfb
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion index.js
Expand Up @@ -6,7 +6,7 @@ import {isGitIgnored, isGitIgnoredSync} from './gitignore.js';
import {FilterStream, toPath, isNegativePattern} from './utilities.js';

const assertPatternsInput = patterns => {
if (!patterns.every(pattern => typeof pattern === 'string')) {
if (patterns.some(pattern => typeof pattern !== 'string')) {
throw new TypeError('Patterns must be a string or an array of strings');
}
};
Expand Down
8 changes: 6 additions & 2 deletions tests/globby.js
Expand Up @@ -91,6 +91,10 @@ test('glob - multiple file paths', async t => {
t.deepEqual(await runGlobby(t, ['a.tmp', 'b.tmp']), ['a.tmp', 'b.tmp']);
});

test('glob - empty patterns', async t => {
t.deepEqual(await runGlobby(t, []), []);
});

test('glob with multiple patterns', async t => {
t.deepEqual(await runGlobby(t, ['a.tmp', '*.tmp', '!{c,d,e}.tmp']), ['a.tmp', 'b.tmp']);
});
Expand All @@ -112,14 +116,14 @@ test('glob - stream async iterator support', async t => {
t.deepEqual(results, ['a.tmp', 'b.tmp', 'c.tmp', 'd.tmp', 'e.tmp']);
});

test.serial('cwd option - sync', async t => {
test.serial('cwd option', async t => {
process.chdir(temporary);
t.deepEqual(await runGlobby(t, '*.tmp', {cwd}), ['a.tmp', 'b.tmp', 'c.tmp', 'd.tmp', 'e.tmp']);
t.deepEqual(await runGlobby(t, ['a.tmp', '*.tmp', '!{c,d,e}.tmp'], {cwd}), ['a.tmp', 'b.tmp']);
process.chdir(cwd);
});

test('don\'t mutate the options object - async', async t => {
test('don\'t mutate the options object', async t => {
await runGlobby(t, ['*.tmp', '!b.tmp'], Object.freeze({ignore: Object.freeze([])}));
t.pass();
});
Expand Down
1 change: 1 addition & 0 deletions tests/utilities.js
Expand Up @@ -21,6 +21,7 @@ export const invalidPatterns = [
[5],
function () {},
[function () {}],
[['string']],
];

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

0 comments on commit bd30cfb

Please sign in to comment.