Skip to content

Commit

Permalink
chore: use relative path when checking against ignoredFileRegex
Browse files Browse the repository at this point in the history
Signed-off-by: Logan McAnsh <logan@mcan.sh>
  • Loading branch information
mcansh committed Mar 13, 2023
1 parent 161072f commit 57b0e6e
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions packages/remix-dev/config/flat-routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export function flatRoutes(

let routes: string[] = [];
for (let entry of entries) {
let filepath: string | undefined = path.join(routesDir, entry.name);
let filepath = path.join(routesDir, entry.name);

let route: string | null = null;
// If it's a directory, don't recurse into it, instead just look for a route module
Expand All @@ -115,7 +115,7 @@ export function flatRoutes(
ignoredFileRegex
);
} else if (entry.isFile()) {
route = findRouteModuleForFile(filepath, ignoredFileRegex);
route = findRouteModuleForFile(appDirectory, filepath, ignoredFileRegex);
}

if (route) routes.push(route);
Expand Down Expand Up @@ -252,10 +252,12 @@ export function flatRoutesUniversal(
}

function findRouteModuleForFile(
appDirectory: string,
filepath: string,
ignoredFileRegex: RegExp[]
): string | null {
let isIgnored = ignoredFileRegex.some((regex) => regex.test(filepath));
let relativePath = path.relative(appDirectory, filepath);
let isIgnored = ignoredFileRegex.some((regex) => regex.test(relativePath));
if (isIgnored) return null;
return filepath;
}
Expand All @@ -265,7 +267,8 @@ function findRouteModuleForFolder(
filepath: string,
ignoredFileRegex: RegExp[]
): string | null {
let isIgnored = ignoredFileRegex.some((regex) => regex.test(filepath));
let relativePath = path.relative(appDirectory, filepath);
let isIgnored = ignoredFileRegex.some((regex) => regex.test(relativePath));
if (isIgnored) return null;

let routeRouteModule = findConfig(filepath, "route", routeModuleExts);
Expand Down

0 comments on commit 57b0e6e

Please sign in to comment.