From c21018d957655ee6aff891d3dc1667a21ddf91c6 Mon Sep 17 00:00:00 2001 From: Guillaume Vincent Date: Wed, 13 Nov 2024 23:46:19 +0100 Subject: [PATCH] fix: class name updater does not support absolute paths Closes #802 If the path given to class name updater is an absolute path, the tool raises an error. It adds the current working dir regardless of the path type. This patch fixes this issue and only adds the current working dir if the file path is not absolute. --- packages/class-name-updater/src/classNameUpdate.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/class-name-updater/src/classNameUpdate.ts b/packages/class-name-updater/src/classNameUpdate.ts index bc2df067..260b3049 100644 --- a/packages/class-name-updater/src/classNameUpdate.ts +++ b/packages/class-name-updater/src/classNameUpdate.ts @@ -1,6 +1,6 @@ import { sync } from "glob"; import { readFileSync, writeFileSync } from "fs"; -import { join } from "path"; +import { isAbsolute, join } from "path"; import { isDir } from "./utils"; import { printDiff } from "./printDiff"; @@ -31,7 +31,7 @@ export async function classNameUpdate( ); includedFiles.forEach(async (file: string) => { - const filePath = join(process.cwd(), file); + const filePath = isAbsolute(file) ? file : join(process.cwd(), file); const isDirectory = await isDir(filePath); const isUnexpectedFile = !acceptedFileTypesRegex.test(filePath);