From 3b2a74fb67977ed65a660e4a2199be7bf8864376 Mon Sep 17 00:00:00 2001 From: James Garbutt <43081j@users.noreply.github.com> Date: Tue, 26 Aug 2025 11:01:20 +0100 Subject: [PATCH] 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'); ``` --- src/config_ignore.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/config_ignore.ts b/src/config_ignore.ts index 75015af..6bc759d 100644 --- a/src/config_ignore.ts +++ b/src/config_ignore.ts @@ -2,7 +2,7 @@ import fastIgnore from "fast-ignore"; import fs from "node:fs/promises"; import path from "node:path"; import Known from "./known.js"; -import { fastJoinedPath, fastRelativeChildPath, isString, isUndefined, memoize, noop, someOf, zipObjectUnless } from "./utils.js"; +import { fastJoinedPath, fastRelativePath, isString, isUndefined, memoize, noop, someOf, zipObjectUnless } from "./utils.js"; import type { Ignore, PromiseMaybe } from "./types.js"; const getIgnoreContent = (folderPath: string, fileName: string): PromiseMaybe => { @@ -27,7 +27,7 @@ const getIgnoresContentMap = async (foldersPaths: string[], filesNames: string[] const getIgnoreBy = (folderPath: string, filesContents: string[]): Ignore => { const ignore = fastIgnore(filesContents); return (filePath: string): boolean => { - const fileRelativePath = fastRelativeChildPath(folderPath, filePath); + const fileRelativePath = fastRelativePath(folderPath, filePath); return !!fileRelativePath && ignore(fileRelativePath); }; };