MCPcopy Create free account
hub / github.com/anus-dev/ANUS / makeRelative

Function makeRelative

packages/core/src/utils/paths.ts:116–127  ·  view source on GitHub ↗
(
  targetPath: string,
  rootDirectory: string,
)

Source from the content-addressed store, hash-verified

114 * @returns The relative path from rootDirectory to targetPath.
115 */
116export function makeRelative(
117 targetPath: string,
118 rootDirectory: string,
119): string {
120 const resolvedTargetPath = path.resolve(targetPath);
121 const resolvedRootDirectory = path.resolve(rootDirectory);
122
123 const relativePath = path.relative(resolvedRootDirectory, resolvedTargetPath);
124
125 // If the paths are the same, path.relative returns '', return '.' instead
126 return relativePath || '.';
127}
128
129/**
130 * Escapes special characters in a file path like macOS terminal does.

Callers 9

getDescriptionMethod · 0.85
shouldConfirmExecuteMethod · 0.85
getDescriptionMethod · 0.85
executeMethod · 0.85
getDescriptionMethod · 0.85
getDescriptionMethod · 0.85
getDescriptionMethod · 0.85
shouldConfirmExecuteMethod · 0.85
getDescriptionMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected