mirror of
https://github.com/wu736139669/hapi.git
synced 2026-08-05 06:24:37 +00:00
feat: support multiple workspace roots (#584)
This commit is contained in:
@@ -1,17 +1,22 @@
|
||||
import { isAbsolute } from 'node:path'
|
||||
|
||||
/**
|
||||
* Resolves the runner's workspace root — the directory tree the runner is
|
||||
* Resolves the runner's workspace roots — the directory trees the runner is
|
||||
* allowed to browse and spawn sessions in. Returns `undefined` when the
|
||||
* user hasn't explicitly opted in; in that case the runner behaves like
|
||||
* the legacy hapi (no scoping, no /browse feature surfaced in the web UI).
|
||||
* legacy hapi (no scoping, no /browse feature surfaced in the web UI).
|
||||
*
|
||||
* The only signal is the `explicit` argument — typically the resolved
|
||||
* `--workspace-root` flag. Non-absolute values are ignored.
|
||||
* `--workspace-root` flag values. Non-absolute values are ignored.
|
||||
*/
|
||||
export function resolveWorkspaceRoot(explicit?: string): string | undefined {
|
||||
if (explicit && isAbsolute(explicit)) {
|
||||
return explicit
|
||||
export function resolveWorkspaceRoots(explicit?: string[]): string[] | undefined {
|
||||
if (!explicit?.length) {
|
||||
return undefined
|
||||
}
|
||||
return undefined
|
||||
|
||||
const uniqueRoots = Array.from(
|
||||
new Set(explicit.filter((path): path is string => typeof path === 'string' && isAbsolute(path)))
|
||||
)
|
||||
|
||||
return uniqueRoots.length > 0 ? uniqueRoots : undefined
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user