File tree Expand file tree Collapse file tree 4 files changed +42
-4
lines changed Expand file tree Collapse file tree 4 files changed +42
-4
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ " trigger.dev " : patch
3
+ ---
4
+
5
+ Fix automatic opening of login URL on linux-server systems with missing xdg-open
Original file line number Diff line number Diff line change 131
131
"engines" : {
132
132
"node" : " >=18.0.0"
133
133
}
134
- }
134
+ }
Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ import { LoginResult } from "../utilities/session.js";
21
21
import { whoAmI } from "./whoami.js" ;
22
22
import { logger } from "../utilities/logger.js" ;
23
23
import { spinner } from "../utilities/windows.js" ;
24
+ import { isLinuxServer } from "../utilities/linux.js" ;
24
25
25
26
export const LoginCommandOptions = CommonCommandOptions . extend ( {
26
27
apiUrl : z . string ( ) ,
@@ -204,10 +205,11 @@ export async function login(options?: LoginOptions): Promise<LoginResult> {
204
205
`Please visit the following URL to login:\n${ chalkLink ( authorizationCodeResult . url ) } `
205
206
) ;
206
207
207
- try {
208
- //this can throw an error on Ubuntu
208
+ if ( await isLinuxServer ( ) ) {
209
+ log . message ( "Please install `xdg-utils` to automatically open the login URL." ) ;
210
+ } else {
209
211
await open ( authorizationCodeResult . url ) ;
210
- } catch ( e ) { }
212
+ }
211
213
212
214
//poll for personal access token (we need to poll for it)
213
215
const getPersonalAccessTokenSpinner = spinner ( ) ;
Original file line number Diff line number Diff line change
1
+ import { spawn } from "child_process" ;
2
+ import { logger } from "./logger" ;
3
+
4
+ export const isLinuxServer = async ( ) => {
5
+ if ( process . platform !== "linux" ) {
6
+ return false ;
7
+ }
8
+
9
+ const xdgAvailable = await new Promise < boolean > ( ( res ) => {
10
+ const xdg = spawn ( "xdg-open" ) ;
11
+
12
+ xdg . on ( "error" , ( error ) => {
13
+ logger . debug ( "Error while checking for xdg-open" , error ) ;
14
+ res ( false ) ;
15
+ } ) ;
16
+
17
+ xdg . on ( "spawn" , ( ) => {
18
+ res ( true ) ;
19
+ } ) ;
20
+
21
+ xdg . on ( "exit" , ( code ) => {
22
+ res ( code === 0 ) ;
23
+ } ) ;
24
+
25
+ xdg . unref ( ) ;
26
+ } ) ;
27
+
28
+ logger . debug ( "xdg-open available:" , xdgAvailable ) ;
29
+
30
+ return ! xdgAvailable ;
31
+ } ;
You can’t perform that action at this time.
0 commit comments