2019-01-09 12:59:46 -05:00
|
|
|
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
|
2019-01-28 20:41:28 -05:00
|
|
|
// tslint:disable-next-line:no-reference
|
|
|
|
/// <reference path="./plugins.d.ts" />
|
2018-11-08 19:09:18 -05:00
|
|
|
|
2019-01-28 20:41:28 -05:00
|
|
|
import "./globals";
|
|
|
|
|
|
|
|
import { log } from "./util";
|
2018-08-17 16:34:30 -04:00
|
|
|
import * as os from "./os";
|
2018-08-25 15:42:49 -04:00
|
|
|
import { libdeno } from "./libdeno";
|
2018-09-22 08:47:44 -04:00
|
|
|
import { args } from "./deno";
|
2018-11-05 12:55:59 -05:00
|
|
|
import { replLoop } from "./repl";
|
2018-06-11 21:54:55 -04:00
|
|
|
|
2019-01-09 12:59:46 -05:00
|
|
|
// builtin modules
|
|
|
|
import * as deno from "./deno";
|
2019-01-06 14:17:13 -05:00
|
|
|
|
2019-01-28 20:41:28 -05:00
|
|
|
// TODO(kitsonk) remove with `--types` below
|
|
|
|
import libDts from "gen/lib/lib.deno_runtime.d.ts!string";
|
2019-01-09 12:59:46 -05:00
|
|
|
|
2018-07-21 21:14:52 -04:00
|
|
|
/* tslint:disable-next-line:no-default-export */
|
|
|
|
export default function denoMain() {
|
2019-01-28 20:41:28 -05:00
|
|
|
const startResMsg = os.start();
|
2018-08-02 13:13:32 -04:00
|
|
|
|
2019-02-12 10:08:56 -05:00
|
|
|
// TODO(kitsonk) remove when import "deno" no longer supported
|
2019-01-09 12:59:46 -05:00
|
|
|
libdeno.builtinModules["deno"] = deno;
|
|
|
|
Object.freeze(libdeno.builtinModules);
|
|
|
|
|
2018-10-15 20:52:33 -04:00
|
|
|
// handle `--version`
|
|
|
|
if (startResMsg.versionFlag()) {
|
|
|
|
console.log("deno:", startResMsg.denoVersion());
|
|
|
|
console.log("v8:", startResMsg.v8Version());
|
2019-01-28 20:41:28 -05:00
|
|
|
// 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);
|
2018-10-15 20:52:33 -04:00
|
|
|
os.exit(0);
|
|
|
|
}
|
|
|
|
|
2018-07-06 11:27:36 -04:00
|
|
|
const cwd = startResMsg.cwd();
|
2018-07-13 03:24:07 -04:00
|
|
|
log("cwd", cwd);
|
2018-06-13 19:40:35 -04:00
|
|
|
|
2018-08-23 19:46:21 -04:00
|
|
|
for (let i = 1; i < startResMsg.argvLength(); i++) {
|
2018-09-22 08:47:44 -04:00
|
|
|
args.push(startResMsg.argv(i));
|
2018-06-13 19:40:35 -04:00
|
|
|
}
|
2018-09-22 08:47:44 -04:00
|
|
|
log("args", args);
|
|
|
|
Object.freeze(args);
|
2018-08-17 16:34:30 -04:00
|
|
|
|
2019-01-09 12:59:46 -05:00
|
|
|
const inputFn = args[0];
|
|
|
|
if (!inputFn) {
|
2018-11-05 12:55:59 -05:00
|
|
|
replLoop();
|
|
|
|
}
|
2018-07-21 21:14:52 -04:00
|
|
|
}
|