0
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-10-30 09:08:00 -04:00
denoland-deno/js/main.ts
Kitson Kelly ee9c627cc5 Split out compiler snapshot (#1566)
Speeds up startup time, reduces runtime heap size.
2019-01-28 20:41:28 -05:00

57 lines
1.4 KiB
TypeScript

// 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.setPid(startResMsg.pid());
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();
}
}