forked from denoland/deno
-
Notifications
You must be signed in to change notification settings - Fork 32
/
main.ts
57 lines (45 loc) · 1.42 KB
/
main.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
// tslint:disable-next-line:no-reference
/// <reference path="./plugins.d.ts" />
import "./globals";
import { log } from "./util";
import * as os from "./os";
import { libdeno } from "./libdeno";
import { args } from "./deno";
import { replLoop } from "./repl";
// builtin modules
import * as deno from "./deno";
// TODO(kitsonk) remove with `--types` below
import libDts from "gen/lib/lib.deno_runtime.d.ts!string";
/* tslint:disable-next-line:no-default-export */
export default function denoMain() {
const startResMsg = os.start();
libdeno.builtinModules["deno"] = deno;
Object.freeze(libdeno.builtinModules);
// handle `--version`
if (startResMsg.versionFlag()) {
console.log("deno:", startResMsg.denoVersion());
console.log("v8:", startResMsg.v8Version());
// TODO figure out a way to restore functionality
// console.log("typescript:", version);
os.exit(0);
}
// handle `--types`
// TODO(kitsonk) move to Rust fetching from compiler
if (startResMsg.typesFlag()) {
console.log(libDts);
os.exit(0);
}
os.setGlobals(startResMsg.pid(), startResMsg.noColor());
const cwd = startResMsg.cwd();
log("cwd", cwd);
for (let i = 1; i < startResMsg.argvLength(); i++) {
args.push(startResMsg.argv(i));
}
log("args", args);
Object.freeze(args);
const inputFn = args[0];
if (!inputFn) {
replLoop();
}
}