From 4b606b59d4654dfccdc81ddaabf87477c682ebbd Mon Sep 17 00:00:00 2001 From: Derek Schuff Date: Wed, 13 Dec 2017 15:53:52 -0800 Subject: [PATCH 1/2] Support node.js in wasm loader The latest LTS of Node supports wasm, and this allows us to test against it, as well as the shells. --- arch/wasm32/wasm.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/arch/wasm32/wasm.js b/arch/wasm32/wasm.js index ce05f21e..d5a9d891 100644 --- a/arch/wasm32/wasm.js +++ b/arch/wasm32/wasm.js @@ -28,6 +28,20 @@ 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); + console.log(file_path); + console.log(filename); + return nodeFS['readFileSync'](filename); + } + var print = console.log; + arguments = process['argv'].slice(2); +} + function setHeap(h) { heap = h heap_uint8 = new Uint8Array(heap); From 190dffd1415cc8be52d4659aced51625d63bdbc1 Mon Sep 17 00:00:00 2001 From: Derek Schuff Date: Fri, 15 Dec 2017 13:23:12 -0800 Subject: [PATCH 2/2] remove extra logging --- arch/wasm32/wasm.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/arch/wasm32/wasm.js b/arch/wasm32/wasm.js index d5a9d891..4743b625 100644 --- a/arch/wasm32/wasm.js +++ b/arch/wasm32/wasm.js @@ -34,8 +34,6 @@ if (typeof process === 'object' && typeof require === 'function') { // This is n const nodePath = require('path'); var read = function(file_path) { filename = nodePath['normalize'](file_path); - console.log(file_path); - console.log(filename); return nodeFS['readFileSync'](filename); } var print = console.log;