Improper typeof check
Closed this issue · 1 comments
Zeludon commented
https://github.com/RonenNess/adder/blob/master/src/index.js#L14
if (typeof window !== undefined) {
window.AdderScript = adder;
};
should be typeof window !== "undefined"
this is causing the module to not work under node for me.
RonenNess commented
Fixed, thanks :)
There was also a confusion with which file to require in Node.js, that's also fixed.
If you want a quick test you can update Adder Script and run the following code:
var AdderScript = require("adder-script")
// init Adder environment (connect output to console)
AdderScript.init({
outputFunc: function(text) {console.log("output from script: " + text);},
});
// create a simple script and compile it
compiledCode = AdderScript.compile('print("Hello World!")');
// spawn a program and execute it
// the result will be an alert with the text "Hello World!".
var program = AdderScript.newProgram(compiledCode);
program.execute();
It should work properly.
Thanks again!