0
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-02-07 23:06:50 -05:00

Add denoMain

This commit is contained in:
Ryan Dahl 2018-05-29 03:43:54 -04:00
parent 95eb8dc5e4
commit b6c0ad15fa
2 changed files with 31 additions and 20 deletions

View file

@ -64,6 +64,9 @@ func main() {
cwd, err := os.Getwd()
check(err)
err = worker.Load("deno_main.js", "denoMain()")
exitOnError(err)
var command = Msg_START // TODO use proto3
PubMsg("start", &Msg{
Command: command,

16
main.ts
View file

@ -17,7 +17,15 @@ import { initFetch } from "./fetch";
export let debug = false;
let startCalled = false;
dispatch.sub("start", (payload: Uint8Array) => {
// denoMain is needed to allow hooks into the system.
// Also eventual snapshot support needs it.
(window as any)["denoMain"] = () => {
delete (window as any)["denoMain"];
initTimers();
initFetch();
dispatch.sub("start", (payload: Uint8Array) => {
if (startCalled) {
throw Error("start message received more than once!");
}
@ -33,11 +41,11 @@ dispatch.sub("start", (payload: Uint8Array) => {
debug = debugFlag;
util.log("start", { cwd, argv, debugFlag });
initTimers();
initFetch();
runtime.setup(mainJs, mainMap);
const inputFn = argv[0];
const mod = runtime.resolveModule(inputFn, `${cwd}/`);
mod.compileAndRun();
});
});
}