diff options
Diffstat (limited to 'src/cdp/discovery.ts')
| -rw-r--r-- | src/cdp/discovery.ts | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/cdp/discovery.ts b/src/cdp/discovery.ts index f33adc6..60fb14f 100644 --- a/src/cdp/discovery.ts +++ b/src/cdp/discovery.ts @@ -101,7 +101,16 @@ type Candidate = { readonly userDataDir: string; }; +// Read here rather than in the client: the daemon owns the only socket to Chrome, so an override the daemon cannot see has no effect. +export const endpointFromEnv = (env: NodeJS.ProcessEnv = process.env): CdpEndpoint | undefined => { + const wsUrl = env["BU_CDP_WS"]?.trim(); + return wsUrl ? { wsUrl } : undefined; +}; + export const discoverEndpoint = async (): Promise<Result<CdpEndpoint, CdpError>> => { + const override = endpointFromEnv(); + if (override) return ok(override); + const dirs = userDataDirCandidates(); const candidates: Candidate[] = []; |
