diff options
author | Ryan Dahl <ry@tinyclouds.org> | 2019-10-04 20:28:51 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-10-04 20:28:51 -0400 |
commit | b81e5db17aa8b3088d6034ddf86b79c69410f012 (patch) | |
tree | 579e4c23d60d1b0d038156bc28a04f74ea87b2f0 /cli/js/main.ts | |
parent | 9049213867d30f7df090a83b6baf3e0717a4d2d2 (diff) |
Merge deno_cli_snapshots into deno_cli (#3064)
Diffstat (limited to 'cli/js/main.ts')
-rw-r--r-- | cli/js/main.ts | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/cli/js/main.ts b/cli/js/main.ts new file mode 100644 index 000000000..09e7ce453 --- /dev/null +++ b/cli/js/main.ts @@ -0,0 +1,41 @@ +// 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 { + const s = os.start(preserveDenoNamespace, name); + + setBuildInfo(s.os, s.arch); + setSignals(); + setVersions(s.denoVersion, s.v8Version, s.tsVersion); + + setPrepareStackTrace(Error); + + if (s.mainModule) { + assert(s.mainModule.length > 0); + setLocation(s.mainModule); + } + + log("cwd", s.cwd); + + for (let i = 1; i < s.argv.length; i++) { + args.push(s.argv[i]); + } + log("args", args); + Object.freeze(args); + + if (!s.mainModule) { + replLoop(); + } +} +window["denoMain"] = denoMain; |