diff --git a/arch/wasm32/wasm.js b/arch/wasm32/wasm.js index ce05f21e..4743b625 100644 --- a/arch/wasm32/wasm.js +++ b/arch/wasm32/wasm.js @@ -28,6 +28,18 @@ var heap; var heap_uint8; var heap_uint32; +if (typeof process === 'object' && typeof require === 'function') { // This is node.js + // Emulate JS shell behavior used below + const nodeFS = require('fs'); + const nodePath = require('path'); + var read = function(file_path) { + filename = nodePath['normalize'](file_path); + return nodeFS['readFileSync'](filename); + } + var print = console.log; + arguments = process['argv'].slice(2); +} + function setHeap(h) { heap = h heap_uint8 = new Uint8Array(heap);