1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-28 16:20:57 -05:00
denoland-deno/main.ts

42 lines
1 KiB
TypeScript
Raw Normal View History

2018-05-27 01:33:21 -04:00
// This allows us to have async/await in our code. It must be loaded first.
import "babel-polyfill";
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
import { initTimers } from "./timers";
2018-05-27 03:46:18 -04:00
import { initFetch } from "./fetch";
2018-05-21 22:07:40 -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 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 = msg.startCwd;
const argv = msg.startArgv;
const debugFlag = msg.startDebugFlag;
const mainJs = msg.startMainJs;
const mainMap = msg.startMainMap;
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-27 03:46:18 -04:00
initFetch();
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
});