Use consistent param names (#12517)

This commit is contained in:
Tommaso Sciortino
2025-11-06 15:03:52 -08:00
committed by GitHub
parent 5f1208ad81
commit f05d937f39
27 changed files with 553 additions and 525 deletions

View File

@@ -233,7 +233,7 @@ export function shortenPath(filePath: string, maxLen: number = 35): string {
/**
* Calculates the relative path from a root directory to a target path.
* Ensures both paths are resolved before calculating.
* If targetPath is relative, it is returned as-is.
* Returns '.' if the target path is the same as the root directory.
*
* @param targetPath The absolute or relative path to make relative.
@@ -244,10 +244,11 @@ export function makeRelative(
targetPath: string,
rootDirectory: string,
): string {
const resolvedTargetPath = path.resolve(targetPath);
if (!path.isAbsolute(targetPath)) {
return targetPath;
}
const resolvedRootDirectory = path.resolve(rootDirectory);
const relativePath = path.relative(resolvedRootDirectory, resolvedTargetPath);
const relativePath = path.relative(resolvedRootDirectory, targetPath);
// If the paths are the same, path.relative returns '', return '.' instead
return relativePath || '.';