mirror of
https://github.com/stablyai/orca.git
synced 2026-11-17 11:24:37 +00:00
* 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>
31 lines
835 B
TypeScript
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
|
|
}
|