@@ -22,13 +22,13 @@ export default class Run extends Command {
2222
2323 public async run ( ) : Promise < void > {
2424 const { args, flags} = await this . parse ( Run )
25-
2625 const discoConfig = getDisco ( flags . disco || null )
2726 const url = `https://${ discoConfig . host } /api/projects/${ flags . project } /runs`
2827 const body = {
2928 command : args . command ,
3029 service : flags . service ?? null ,
3130 timeout : flags . timeout ,
31+ interactive : true ,
3232 }
3333 const res = await request ( { method : 'POST' , url, discoConfig, body, expectedStatuses : [ 202 ] } )
3434 const respBody = ( await res . json ( ) ) as { run : {
@@ -48,14 +48,22 @@ export default class Run extends Command {
4848 process . stderr . write ( restOfMessage ) ;
4949 } else if ( prefix === 's:' ) {
5050 const statusCode = Number . parseInt ( restOfMessage . toString ( 'utf8' ) , 10 ) ;
51- this . exit ( statusCode ) ;
51+ process . exitCode = statusCode ;
52+ ws . close ( 1000 ) ;
53+ process . stdin . removeListener ( 'data' , stdinHandler ) ;
54+ process . stdin . setRawMode ( false ) ;
55+ process . stdin . pause ( ) ;
5256 }
5357 }
5458 } ) ;
59+ const stdinHandler = ( key : any ) => {
60+ ws . send ( key , { binary : true } ) ;
61+ } ;
5562 process . stdin . setRawMode ( true ) ;
5663 process . stdin . resume ( ) ;
57- process . stdin . on ( 'data' , ( key ) => {
58- ws . send ( key , { binary : true } ) ;
64+ process . stdin . on ( 'data' , stdinHandler ) ;
65+ ws . on ( 'close' , ( ) => {
66+ process . stdin . removeListener ( 'data' , stdinHandler ) ;
5967 } ) ;
6068 }
6169}
0 commit comments