File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed
packages/npm-packages/ruby-wasm-wasi/src Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ export const DefaultRubyVM = async (
1616
1717 if ( options . consolePrint ) {
1818 const originalWriteSync = wasmFs . fs . writeSync . bind ( wasmFs . fs ) ;
19+ const stdOutErrBuffers = { 1 : "" , 2 : "" } ;
1920 wasmFs . fs . writeSync = function ( ) {
2021 let fd : number = arguments [ 0 ] ;
2122 let text : string ;
@@ -29,7 +30,15 @@ export const DefaultRubyVM = async (
2930 1 : ( line : string ) => console . log ( line ) ,
3031 2 : ( line : string ) => console . warn ( line ) ,
3132 } ;
32- if ( handlers [ fd ] ) handlers [ fd ] ( text ) ;
33+ if ( handlers [ fd ] ) {
34+ text = stdOutErrBuffers [ fd ] + text ;
35+ let i = text . lastIndexOf ( "\n" ) ;
36+ if ( i >= 0 ) {
37+ handlers [ fd ] ( text . substring ( 0 , i + 1 ) ) ;
38+ text = text . substring ( i + 1 ) ;
39+ }
40+ stdOutErrBuffers [ fd ] = text ;
41+ }
3342 return originalWriteSync ( ...arguments ) ;
3443 } ;
3544 }
You can’t perform that action at this time.
0 commit comments