Skip to content

Commit ab729cf

Browse files
committedJun 26, 2023
rtlib/emscripten: when running under node.js write directly to process.stdout
This fixes an extra newline being appended after every PRINT due to console.log(). This is a quick fix just for write() in fb_rtlib.js. No other rtlib functions, e.g. COLOR, are implemented. But there's really no overlap between the existing termlib.js-based fb_rtlib.js and one that directly accesses a tty through node.js, so we should just have a separate .js file for that.
1 parent 24927ee commit ab729cf

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed
 

‎lib/fb_rtlib.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,13 @@ var __fb_rtlib =
5353
{
5454
if( this.term === null )
5555
{
56-
console.log(text);
56+
// Under node.js write to stdout. console.log adds an extra newline
57+
if( typeof process !== 'undefined' )
58+
process.stdout.write(text);
59+
else
60+
console.log(text);
5761
return;
5862
}
59-
6063
this.term.write('%c(' + this.fg_color + ',' + this.bg_color + ')' + text.replace('%(', '%%('));
6164
},
6265

0 commit comments

Comments
 (0)
Please sign in to comment.