-
Notifications
You must be signed in to change notification settings - Fork 17
/
run.js
18 lines (18 loc) · 811 Bytes
/
run.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
var fs = require("fs");
var emitter = require("./translator/emitter");
var proc = require("child_process");
var pref = 'try{\r\n';
var postf = '\r\n} catch(e){ __LastXpCall(e) }\r\n';
var fn = process.argv[2];
var flua = fn.replace(".js", ".lua");
if (fn == flua)
throw new Error("cannot overwrite files!");
var luaRT = fs.readFileSync("runtime/runtime.lua").toString();
var source = fs.readFileSync(fn).toString();
var polyfills = fs.readFileSync("runtime/polyfills.js").toString();
var luasrc = emitter.convertFile(polyfills + pref + source + postf, fn, false);
fs.writeFileSync(flua, luaRT + luasrc);
var profile = false;
//(profile ? "-jp=a " : "") + flua
var rc = proc.spawn("cmd", ["/c \\bin\\luajit\\luajit " + (profile ? "-jp=a " : "") + flua], { stdio: 'inherit' });
//# sourceMappingURL=run.js.map