File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22// Coordinates: initiate → display code → open browser → poll → return credentials.
33// Works in both CLI mode (ora spinner) and REPL mode (terminal.dim).
44
5- import { spawn } from "node:child_process" ;
5+ import { execFileSync , spawn } from "node:child_process" ;
66import ora , { type Ora } from "ora" ;
77import type { AuthResource } from "../api/resources/auth.ts" ;
88import { getApiClient } from "../api/client.ts" ;
@@ -47,7 +47,18 @@ async function openBrowser(url: string): Promise<boolean> {
4747 cmd = "open" ;
4848 args = [ url ] ;
4949 } else {
50- cmd = "xdg-open" ;
50+ // Linux/WSL: fallback chain (GitHub CLI pattern — cli/browser)
51+ // wslview works in WSL, xdg-open works in native Linux
52+ const found = [ "xdg-open" , "wslview" ] . find ( ( c ) => {
53+ try {
54+ execFileSync ( "which" , [ c ] , { stdio : "ignore" } ) ;
55+ return true ;
56+ } catch {
57+ return false ;
58+ }
59+ } ) ;
60+ if ( ! found ) return false ;
61+ cmd = found ;
5162 args = [ url ] ;
5263 }
5364
You can’t perform that action at this time.
0 commit comments