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 (
16
16
17
17
if ( options . consolePrint ) {
18
18
const originalWriteSync = wasmFs . fs . writeSync . bind ( wasmFs . fs ) ;
19
+ const stdOutErrBuffers = { 1 : "" , 2 : "" } ;
19
20
wasmFs . fs . writeSync = function ( ) {
20
21
let fd : number = arguments [ 0 ] ;
21
22
let text : string ;
@@ -29,7 +30,15 @@ export const DefaultRubyVM = async (
29
30
1 : ( line : string ) => console . log ( line ) ,
30
31
2 : ( line : string ) => console . warn ( line ) ,
31
32
} ;
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
+ }
33
42
return originalWriteSync ( ...arguments ) ;
34
43
} ;
35
44
}
You can’t perform that action at this time.
0 commit comments