0
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-03-04 01:44:26 -05:00
deno/main.ts

48 lines
1 KiB
TypeScript
Raw Normal View History

2018-05-14 03:06:09 -04:00
import { main as pb } from "./msg.pb";
2018-05-14 01:30:56 -04:00
import "./util";
import * as runtime from "./runtime";
2018-05-18 11:49:28 -04:00
import * as timers from "./timers";
2018-05-19 05:38:51 -04:00
import * as util from "./util";
2018-05-14 01:30:56 -04:00
2018-05-19 05:38:51 -04:00
// To control internal logging output
// Set with the -debug command-line flag.
export let debug = false;
2018-05-21 17:33:33 -04:00
function start(
cwd: string,
argv: string[],
debugFlag: boolean,
mainJs: string,
mainMap: string
): void {
2018-05-19 05:38:51 -04:00
debug = debugFlag;
util.log("start", { cwd, argv, debugFlag });
2018-05-19 07:06:23 -04:00
2018-05-21 17:33:33 -04:00
runtime.setup(mainJs, mainMap);
2018-05-19 05:38:51 -04:00
const inputFn = argv[0];
2018-05-19 04:47:40 -04:00
const mod = runtime.resolveModule(inputFn, cwd + "/");
mod.compileAndRun();
2018-05-14 01:30:56 -04:00
}
2018-05-13 23:32:01 -04:00
2018-05-14 01:19:23 -04:00
V8Worker2.recv((ab: ArrayBuffer) => {
2018-05-14 01:30:56 -04:00
const msg = pb.Msg.decode(new Uint8Array(ab));
2018-05-17 21:02:06 -04:00
switch (msg.payload) {
case "start":
2018-05-21 17:33:33 -04:00
start(
msg.start.cwd,
msg.start.argv,
msg.start.debugFlag,
msg.start.mainJs,
msg.start.mainMap
);
2018-05-14 03:15:21 -04:00
break;
2018-05-18 11:49:28 -04:00
case "timerReady":
timers.timerReady(msg.timerReady.id, msg.timerReady.done);
break;
2018-05-14 03:15:21 -04:00
default:
console.log("Unknown message", msg);
break;
2018-05-14 01:30:56 -04:00
}
2018-05-14 00:31:48 -04:00
});