Skip to content

Commit

Permalink
Change findFileConfig logic again
Browse files Browse the repository at this point in the history
  • Loading branch information
yanthomasdev committed Nov 13, 2024
1 parent f3e0577 commit 5f38136
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions packages/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,18 +236,11 @@ class Lunaria {
/** Finds the matching `files` configuration for the specified path. */
findFileConfig(path: string) {
return this.config.files.find((file) => {
const { isSourcePath, toPath } = this.getPathResolver(file.pattern);

const { isSourcePath, isLocalesPath } = this.getPathResolver(file.pattern);
try {
const sourcePath = isSourcePath(path) ? path : toPath(path, this.config.sourceLocale.lang);

// Checks if the path matches the `include` and `exclude` fields.
return picomatch.isMatch(sourcePath, file.include, {
ignore: file.exclude,
});

// If it fails to match, we assume it's not the respective `files` config and return false.
return isSourcePath(path) || isLocalesPath(path);
} catch {
// If it fails to match, we assume it's not the respective `files` config and return false.
return false;
}
});
Expand Down

0 comments on commit 5f38136

Please sign in to comment.