Skip to content

Commit 3b2a74f

Browse files
committed
fix: use fastRelativePath when processing ignore paths
An ignore path can be relative. For example: - folder can be `/foo/configs` - file can be `/foo/src/index.ts` - the ignore file can be `/foo/configs/.prettierignore` - the ignore contents can be `../src/index.ts` This means we end up doing: ``` // does not fall back to path.relative fastRelativeChildPath('/foo/configs', '/foo/src/index.ts'); ``` Which fails since we actually need `fastRelativePath`: ``` // falls back to path.relative fastRelativePath('/foo/configs', '/foo/src/index.ts'); ```
1 parent 4b1a66a commit 3b2a74f

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/config_ignore.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import fastIgnore from "fast-ignore";
22
import fs from "node:fs/promises";
33
import path from "node:path";
44
import Known from "./known.js";
5-
import { fastJoinedPath, fastRelativeChildPath, isString, isUndefined, memoize, noop, someOf, zipObjectUnless } from "./utils.js";
5+
import { fastJoinedPath, fastRelativePath, isString, isUndefined, memoize, noop, someOf, zipObjectUnless } from "./utils.js";
66
import type { Ignore, PromiseMaybe } from "./types.js";
77

88
const getIgnoreContent = (folderPath: string, fileName: string): PromiseMaybe<string | undefined> => {
@@ -27,7 +27,7 @@ const getIgnoresContentMap = async (foldersPaths: string[], filesNames: string[]
2727
const getIgnoreBy = (folderPath: string, filesContents: string[]): Ignore => {
2828
const ignore = fastIgnore(filesContents);
2929
return (filePath: string): boolean => {
30-
const fileRelativePath = fastRelativeChildPath(folderPath, filePath);
30+
const fileRelativePath = fastRelativePath(folderPath, filePath);
3131
return !!fileRelativePath && ignore(fileRelativePath);
3232
};
3333
};

0 commit comments

Comments
 (0)