Skip to content

Commit

Permalink
Fix double newline using browser shim (bytecodealliance#502)
Browse files Browse the repository at this point in the history
Signed-off-by: Jorge Prendes <[email protected]>
  • Loading branch information
jprendes authored Sep 17, 2024
1 parent 3435f0b commit 0bf599f
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion packages/preview2-shim/lib/browser/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ const stdinStream = new InputStream({
let textDecoder = new TextDecoder();
const stdoutStream = new OutputStream({
write (contents) {
if (contents[contents.length - 1] == 10) {
// console.log already appends a new line
contents = contents.subarray(0, contents.length - 1);
}
console.log(textDecoder.decode(contents));
},
blockingFlush () {
Expand All @@ -84,10 +88,13 @@ const stdoutStream = new OutputStream({
});
const stderrStream = new OutputStream({
write (contents) {
if (contents[contents.length - 1] == 10) {
// console.error already appends a new line
contents = contents.subarray(0, contents.length - 1);
}
console.error(textDecoder.decode(contents));
},
blockingFlush () {

},
[symbolDispose] () {

Expand Down

0 comments on commit 0bf599f

Please sign in to comment.