0
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-10-31 09:14:20 -04:00
denoland-deno/js/main.ts

57 lines
1.4 KiB
TypeScript
Raw Normal View History

// 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";
2018-06-11 21:54:55 -04:00
// builtin modules
import * as deno from "./deno";
// TODO(kitsonk) remove with `--types` below
import libDts from "gen/lib/lib.deno_runtime.d.ts!string";
2018-07-21 21:14:52 -04:00
/* tslint:disable-next-line:no-default-export */
export default function denoMain() {
const startResMsg = os.start();
// TODO(kitsonk) remove when import "deno" no longer supported
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);
}
const cwd = startResMsg.cwd();
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++) {
args.push(startResMsg.argv(i));
2018-06-13 19:40:35 -04:00
}
log("args", args);
Object.freeze(args);
const inputFn = args[0];
if (!inputFn) {
replLoop();
}
2018-07-21 21:14:52 -04:00
}