MCPcopy Index your code
hub / github.com/callstack/agent-device / openBrowser

Function openBrowser

src/cli/auth-session.ts:543–560  ·  view source on GitHub ↗
(url: string, io?: AuthIo)

Source from the content-addressed store, hash-verified

541}
542
543async function openBrowser(url: string, io?: AuthIo): Promise<void> {
544 if (io?.openBrowser) {
545 await io.openBrowser(url);
546 return;
547 }
548 const platform = process.platform;
549 try {
550 if (platform === 'darwin') {
551 await runCmd('open', [url], { allowFailure: true, timeoutMs: 5000 });
552 } else if (platform === 'win32') {
553 await runCmd('cmd', ['/c', 'start', '', url], { allowFailure: true, timeoutMs: 5000 });
554 } else {
555 await runCmd('xdg-open', [url], { allowFailure: true, timeoutMs: 5000 });
556 }
557 } catch {
558 writeStderr(io, `Open this URL on your machine:\n${url}\n`);
559 }
560}
561
562function writeStderr(io: AuthIo | undefined, text: string): void {
563 (io?.stderr ?? process.stderr).write(text);

Callers 1

loginWithDeviceAuthFunction · 0.85

Calls 2

runCmdFunction · 0.90
writeStderrFunction · 0.85

Tested by

no test coverage detected