Skip to content

Commit

Permalink
Use path.posix in pattern modifiers for globs
Browse files Browse the repository at this point in the history
  • Loading branch information
webpro committed Oct 21, 2022
1 parent 838f666 commit 9ab4d81
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ export const main = async (unresolvedConfiguration: UnresolvedConfiguration) =>

updateMessage('Resolving entry files...');
const entryPaths = await resolvePaths({
cwd,
workingDir,
patterns: resolvedConfig.entryFiles,
ignore,
Expand All @@ -96,6 +97,7 @@ export const main = async (unresolvedConfiguration: UnresolvedConfiguration) =>

updateMessage('Resolving project files...');
const projectPaths = await resolvePaths({
cwd,
workingDir,
patterns: resolvedConfig.projectFiles,
ignore,
Expand Down
8 changes: 5 additions & 3 deletions src/util/path.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,18 @@ const glob = async function (patterns: readonly string[], options: Options) {
};

const prependDirToPattern = (workingDir: string, pattern: string) => {
if (pattern.startsWith('!')) return '!' + path.join(workingDir, pattern.slice(1));
return path.join(workingDir, pattern);
if (pattern.startsWith('!')) return '!' + path.posix.join(workingDir, pattern.slice(1));
return path.posix.join(workingDir, pattern);
};

export const resolvePaths = async ({
cwd,
workingDir,
patterns,
ignore,
gitignore,
}: {
cwd: string;
workingDir: string;
patterns: string[];
ignore: string[];
Expand All @@ -33,7 +35,7 @@ export const resolvePaths = async ({
glob(
// Prepend relative --dir to patterns to use cwd (not workingDir), because
// we want to glob everything to include all (git)ignore patterns
patterns.map(pattern => prependDirToPattern(relative(workingDir), pattern)),
patterns.map(pattern => prependDirToPattern(path.posix.relative(cwd, workingDir), pattern)),
{
cwd,
ignore: [...ignore, '**/node_modules'],
Expand Down

0 comments on commit 9ab4d81

Please sign in to comment.