Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Ensure async method is completely async
Fixes #190
  • Loading branch information
sindresorhus committed Aug 24, 2021
1 parent c69526f commit e167725
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions index.js
Expand Up @@ -96,7 +96,19 @@ const getFilterSync = options => options && options.gitignore
? isGitIgnoredSync({cwd: options.cwd, ignore: options.ignore})
: DEFAULT_FILTER;

const globToTask = task => glob => {
const globToTask = task => async glob => {
const {options} = task;
if (options.ignore && Array.isArray(options.ignore) && options.expandDirectories) {
options.ignore = await dirGlob(options.ignore);
}

return {
pattern: glob,
options,
};
};

const globToTaskSync = task => glob => {
const {options} = task;
if (options.ignore && Array.isArray(options.ignore) && options.expandDirectories) {
options.ignore = dirGlob.sync(options.ignore);
Expand Down Expand Up @@ -135,7 +147,7 @@ export const globbySync = (patterns, options) => {

const tasks = [];
for (const task of globTasks) {
const newTask = getPattern(task, dirGlob.sync).map(globToTask(task));
const newTask = getPattern(task, dirGlob.sync).map(globToTaskSync(task));
tasks.push(...newTask);
}

Expand All @@ -154,7 +166,7 @@ export const globbyStream = (patterns, options) => {

const tasks = [];
for (const task of globTasks) {
const newTask = getPattern(task, dirGlob.sync).map(globToTask(task));
const newTask = getPattern(task, dirGlob.sync).map(globToTaskSync(task));
tasks.push(...newTask);
}

Expand Down

0 comments on commit e167725

Please sign in to comment.