deno/cli/js/main.ts

39 lines
1,018 B
TypeScript
Raw Normal View History

2020-01-02 20:13:47 +00:00
// Copyright 2018-2020 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 { setLocation } from "./location.ts";
import { setBuildInfo } from "./build.ts";
import { setSignals } from "./process.ts";
function bootstrapMainRuntime(): void {
const s = os.start(true);
setBuildInfo(s.os, s.arch);
setSignals();
setVersions(s.denoVersion, s.v8Version, s.tsVersion);
setPrepareStackTrace(Error);
2019-08-26 12:50:21 +00:00
if (s.mainModule) {
assert(s.mainModule.length > 0);
setLocation(s.mainModule);
2019-02-13 02:14:02 +00:00
}
2019-08-26 12:50:21 +00:00
log("cwd", s.cwd);
for (let i = 0; i < s.argv.length; i++) {
2019-08-26 12:50:21 +00:00
args.push(s.argv[i]);
2018-06-13 23:40:35 +00:00
}
log("args", args);
Object.freeze(args);
2019-10-04 13:02:36 +00:00
if (!s.mainModule) {
replLoop();
}
2018-07-22 01:14:52 +00:00
}
globalThis["bootstrapMainRuntime"] = bootstrapMainRuntime;