1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-24 15:19:26 -05:00
denoland-deno/main.ts

34 lines
868 B
TypeScript
Raw Normal View History

2018-05-21 22:07:40 -04:00
import * as dispatch from "./dispatch";
2018-05-14 03:06:09 -04:00
import { main as pb } from "./msg.pb";
2018-05-21 22:07:40 -04:00
import * as runtime from "./runtime";
2018-05-19 05:38:51 -04:00
import * as util from "./util";
2018-05-14 01:30:56 -04:00
2018-05-21 22:07:40 -04:00
// These have top-level functions that need to execute.
import { initTimers } from "./timers";
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 22:07:40 -04:00
let startCalled = false;
dispatch.sub("start", (payload: Uint8Array) => {
if (startCalled) {
throw Error("start message received more than once!");
}
startCalled = true;
const msg = pb.Msg.decode(payload);
const { cwd, argv, debugFlag, mainJs, mainMap } = msg.start;
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 22:07:40 -04:00
initTimers();
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 00:31:48 -04:00
});