Skip to content

Commit

Permalink
fix findUp call
Browse files Browse the repository at this point in the history
`findUp` can search for a file or a directory, not both.
  • Loading branch information
Jason3S committed Oct 6, 2024
1 parent 3976d23 commit 2a9f016
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/cspell-gitignore/src/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@ export function factoryPathHelper(path: PathInterface): PathHelper {
}

async function findRepoRoot(directory: string): Promise<string | undefined> {
const found = await findUp('.git', { cwd: directory });
const foundDir = (await findUp('.git', { cwd: directory, type: 'directory' })) || '';
const foundFile = (await findUp('.git', { cwd: directory, type: 'file' })) || '';
const found = foundDir.length >= foundFile.length ? foundDir : foundFile;
if (!found) return undefined;
return path.dirname(found);
}
Expand Down

0 comments on commit 2a9f016

Please sign in to comment.