From 5b9bc08d2f3726afa4f13d831d506968fbbe8553 Mon Sep 17 00:00:00 2001 From: bas-d <7903735+bas-d@users.noreply.github.com> Date: Sun, 12 May 2019 13:04:11 +0200 Subject: [PATCH] Properly check if console exists. --- dist-build/emscripten.sh | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/dist-build/emscripten.sh b/dist-build/emscripten.sh index 8fa9d77b..1a5c32b3 100755 --- a/dist-build/emscripten.sh +++ b/dist-build/emscripten.sh @@ -99,6 +99,16 @@ if [ "$DIST" = yes ]; then Module.ready = new Promise(function(resolve, reject) { var Module = _Module; Module.onAbort = reject; + Module.print = function(what) { + if (typeof(console) !== 'undefined') { + console.log(what); + } + } + Module.printErr = function(what) { + if (typeof(console) !== 'undefined') { + console.warn(what); + } + } Module.onRuntimeInitialized = function() { try { /* Test arbitrary wasm function */