0
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-01 09:24:20 -04:00
denoland-deno/cli/js/main.ts

42 lines
1.1 KiB
TypeScript
Raw Normal View History

// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
import "./globals.ts";
import { assert, log } from "./util.ts";
import * as os from "./os.ts";
import { args } from "./deno.ts";
import { setPrepareStackTrace } from "./error_stack.ts";
import { replLoop } from "./repl.ts";
import { setVersions } from "./version.ts";
import { window } from "./window.ts";
import { setLocation } from "./location.ts";
import { setBuildInfo } from "./build.ts";
import { setSignals } from "./process.ts";
function denoMain(preserveDenoNamespace = true, name?: string): void {
2019-08-26 08:50:21 -04:00
const s = os.start(preserveDenoNamespace, name);
setBuildInfo(s.os, s.arch);
setSignals();
setVersions(s.denoVersion, s.v8Version, s.tsVersion);
setPrepareStackTrace(Error);
2019-08-26 08:50:21 -04:00
if (s.mainModule) {
assert(s.mainModule.length > 0);
setLocation(s.mainModule);
2019-02-12 21:14:02 -05:00
}
2019-08-26 08:50:21 -04:00
log("cwd", s.cwd);
2018-06-13 19:40:35 -04:00
2019-08-26 08:50:21 -04:00
for (let i = 1; i < s.argv.length; i++) {
args.push(s.argv[i]);
2018-06-13 19:40:35 -04:00
}
log("args", args);
Object.freeze(args);
2019-10-04 09:02:36 -04:00
if (!s.mainModule) {
replLoop();
}
2018-07-21 21:14:52 -04:00
}
window["denoMain"] = denoMain;