From b351a2e3766ca9bc64039ee455bb1da5cfa65867 Mon Sep 17 00:00:00 2001 From: brettkolodny Date: Fri, 17 Feb 2023 10:15:19 -0500 Subject: fix: deno print_error and print_debug to match node implementation --- src/gleam_stdlib.mjs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/gleam_stdlib.mjs') diff --git a/src/gleam_stdlib.mjs b/src/gleam_stdlib.mjs index 8532821..60ab625 100644 --- a/src/gleam_stdlib.mjs +++ b/src/gleam_stdlib.mjs @@ -276,7 +276,7 @@ export function print(string) { if (typeof process === "object") { process.stdout.write(string); // We can write without a trailing newline } else if (typeof Deno === "object") { - Deno.stdout.writeSync(new TextEncoder().encode(string)); + Deno.stdout.writeSync(new TextEncoder().encode(string)); // We can write without a trailing newline } else { console.log(string); // We're in a browser. Newlines are mandated } @@ -285,6 +285,8 @@ export function print(string) { export function print_error(string) { if (typeof process === "object") { process.stderr.write(string); // We can write without a trailing newline + } else if (typeof Deno === "object") { + Deno.stderr.writeSync(new TextEncoder().encode(string)); // We can write without a trailing newline } else { console.error(string); // We're in a browser. Newlines are mandated } @@ -293,6 +295,8 @@ export function print_error(string) { export function print_debug(string) { if (typeof process === "object") { process.stderr.write(string + "\n"); // If we're in Node.js, use `stderr` + } else if (typeof Deno === "object") { + Deno.stderr.writeSync(new TextEncoder().encode(string + "\n")); // If we're in Deno, use `stderr` } else { console.log(string); // Otherwise, use `console.log` (so that it doesn't look like an error) } -- cgit v1.2.3