Skip to content

Commit

Permalink
Avoid cwd: undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
fisker committed Jan 19, 2022
1 parent 61c2eb1 commit 773990f
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions index.js
Expand Up @@ -94,9 +94,10 @@ const generateGlobTasksInternal = (patterns, taskOptions) => {
return globTasks;
};

const getDirGlobOptions = (options, cwd) => Array.isArray(options)
? {cwd, files: options}
: {...options, cwd};
const getDirGlobOptions = (options, cwd) => ({
...(cwd ? {cwd} : {}),
...(Array.isArray(options) ? {files: options} : options),
});

const generateTasks = async (patterns, options) => {
const globTasks = generateGlobTasksInternal(patterns, options);
Expand All @@ -118,7 +119,7 @@ const generateTasks = async (patterns, options) => {
ignore,
] = await Promise.all([
dirGlob(pattern, dirGlobOptions),
dirGlob(options.ignore, {cwd}),
dirGlob(options.ignore, cwd ? {cwd} : undefined),
]);

options.ignore = ignore;
Expand All @@ -143,7 +144,7 @@ const generateTasksSync = (patterns, options) => {
return globTasks.flatMap(task => {
const {pattern, options} = task;
const patterns = dirGlob.sync(pattern, dirGlobOptions);
options.ignore = dirGlob.sync(options.ignore, {cwd});
options.ignore = dirGlob.sync(options.ignore, cwd ? {cwd} : undefined);
return patterns.map(pattern => ({pattern, options}));
});
};
Expand Down

0 comments on commit 773990f

Please sign in to comment.