File tree Expand file tree Collapse file tree
packages/opencode/src/cli/cmd Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -762,10 +762,15 @@ export const RunCommand = effectCmd({
762762
763763 if ( ! args . interactive ) {
764764 const events = await client . event . subscribe ( )
765- loop ( client , events ) . catch ( ( e ) => {
765+ const completed = loop ( client , events ) . catch ( ( e ) => {
766766 console . error ( e )
767- process . exit ( 1 )
767+ process . exitCode = 1
768768 } )
769+ async function finish ( ) {
770+ if ( args . attach ) return
771+ const error = await completed
772+ if ( error ) process . exitCode = 1
773+ }
769774
770775 if ( args . command ) {
771776 const result = await client . session . command ( {
@@ -779,7 +784,9 @@ export const RunCommand = effectCmd({
779784 if ( result . error ) {
780785 if ( ! emit ( "error" , { error : result . error } ) ) UI . error ( formatRunError ( result . error ) )
781786 process . exitCode = 1
787+ return
782788 }
789+ await finish ( )
783790 return
784791 }
785792
@@ -794,7 +801,9 @@ export const RunCommand = effectCmd({
794801 if ( result . error ) {
795802 if ( ! emit ( "error" , { error : result . error } ) ) UI . error ( formatRunError ( result . error ) )
796803 process . exitCode = 1
804+ return
797805 }
806+ await finish ( )
798807 return
799808 }
800809
You can’t perform that action at this time.
0 commit comments