@wpkernel/cli / toWorkspaceRelative
Function: toWorkspaceRelative()
ts
function toWorkspaceRelative(workspace, targetPath): string;Converts a target path to a workspace-relative POSIX path when possible.
workspacemay be a Workspace-like object with arootproperty or a string root path.targetPathmay be absolute or relative; relative paths are resolved against the workspace root.- If the resolved path is inside the workspace, a relative POSIX path is returned ('.' for the root).
- If the resolved path is outside the workspace, the absolute path is returned, normalised to POSIX separators.
Parameters
workspace
WorkspaceLike
targetPath
string
Returns
string
