1- import { execFile } from 'node:child_process'
1+ import { spawn } from 'node:child_process'
22import fs from 'node:fs'
33import http from 'node:http'
44import https from 'node:https'
@@ -17,14 +17,14 @@ export async function login(positionals: string[], _flags: Record<string, string
1717
1818 const server = ssh . split ( '@' ) . pop ( ) !
1919
20- const spin = spinner ( `Connecting to ${ ssh } ...` )
20+ logInfo ( `Connecting to ${ ssh } ...` )
2121 const jwt = await sshMintJwt ( ssh )
2222 if ( ! jwt ) {
23- spin . stop ( )
2423 logError ( `Connection failed — check that you can ssh to ${ ssh } ` )
2524 process . exit ( 1 )
2625 }
2726
27+ const spin = spinner ( `Resolving zero API on ${ server } ...` )
2828 const host = await resolveApiUrl ( server , jwt )
2929 spin . stop ( )
3030 if ( ! host ) {
@@ -42,8 +42,14 @@ const SSH_COMMAND =
4242
4343function sshExec ( ssh : string , command : string ) : Promise < { stdout : string ; ok : boolean } > {
4444 return new Promise ( ( resolve ) => {
45- execFile ( 'ssh' , [ ssh , command ] , { timeout : 30_000 } , ( err , stdout ) => {
46- if ( err ) {
45+ const child = spawn ( 'ssh' , [ ssh , command ] , { stdio : [ 'inherit' , 'pipe' , 'inherit' ] } )
46+ let stdout = ''
47+ child . stdout . on ( 'data' , ( chunk ) => {
48+ stdout += chunk . toString ( )
49+ } )
50+ child . on ( 'error' , ( ) => resolve ( { stdout : '' , ok : false } ) )
51+ child . on ( 'close' , ( code ) => {
52+ if ( code !== 0 ) {
4753 resolve ( { stdout : '' , ok : false } )
4854 return
4955 }
0 commit comments