Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor tweak #226

Merged
merged 4 commits into from Jan 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion index.js
Expand Up @@ -8,7 +8,7 @@ import {FilterStream, toPath} from './utilities.js';
const isNegative = pattern => pattern[0] === '!';

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;