Files
orca/src/cli/repo-path-arguments.ts
T
OrcaWinandOrcaWin 9aa208a4ab [comment audit] Shorten remaining CLI root comments (#32273)
* chore: shorten process-host comments

* chore: audit CLI parsing and host-routing comments

* chore: remove stale host-selector restriction comment

* chore: shorten remaining CLI root comments

---------

Co-authored-by: OrcaWin <293788423+OrcaWin@users.noreply.github.com>
2026-10-23 08:07:03 -07:00

31 lines
835 B
TypeScript

import { resolve as resolvePath } from 'node:path'
import { RuntimeClientError } from './runtime-client'
function isAbsoluteServerPath(value: string): boolean {
return (
value.startsWith('/') ||
/^[A-Za-z]:[\\/]/.test(value) ||
value.startsWith('\\\\') ||
value.startsWith('//')
)
}
export function resolveRepoPathArgument(
inputPath: string,
cwd: string,
isRemote: boolean,
remotePathSubject = 'Remote repo path'
): string {
if (!isRemote) {
return resolvePath(cwd, inputPath)
}
// The client cwd belongs to a different filesystem from a paired runtime's relative paths.
if (!isAbsoluteServerPath(inputPath)) {
throw new RuntimeClientError(
'invalid_argument',
`${remotePathSubject} requires --path to be an absolute path on the remote server.`
)
}
return inputPath
}