summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
Diffstat (limited to 'js')
-rw-r--r--js/main.ts9
-rw-r--r--js/util.ts15
2 files changed, 17 insertions, 7 deletions
diff --git a/js/main.ts b/js/main.ts
index 667e115f5..c712f7e08 100644
--- a/js/main.ts
+++ b/js/main.ts
@@ -2,6 +2,8 @@
import { flatbuffers } from "flatbuffers";
import { deno as fbs } from "gen/msg_generated";
import { assert, log, assignCmdId } from "./util";
+import * as util from "./util";
+import * as os from "./os";
import * as runtime from "./runtime";
import { libdeno } from "./globals";
import * as timers from "./timers";
@@ -60,6 +62,8 @@ export default function denoMain() {
const startResMsg = new fbs.StartRes();
assert(base.msg(startResMsg) != null);
+ util.setLogDebug(startResMsg.debugFlag());
+
const cwd = startResMsg.cwd();
log("cwd", cwd);
@@ -70,6 +74,11 @@ export default function denoMain() {
log("argv", argv);
const inputFn = argv[1];
+ if (!inputFn) {
+ console.log("No input script specified.");
+ os.exit(1);
+ }
+
const mod = runtime.resolveModule(inputFn, `${cwd}/`);
assert(mod != null);
// TypeScript does not track assert, therefore not null assertion
diff --git a/js/util.ts b/js/util.ts
index c1e84610f..c03e47140 100644
--- a/js/util.ts
+++ b/js/util.ts
@@ -1,16 +1,17 @@
// Copyright 2018 the Deno authors. All rights reserved. MIT license.
+import { TypedArray } from "./types";
-//import { debug } from "./main";
-const debug = false;
+let logDebug = false;
-import { TypedArray } from "./types";
+export function setLogDebug(debug: boolean): void {
+ logDebug = debug;
+}
-// Internal logging for deno. Use the "debug" variable above to control
-// output.
+// Debug logging for deno. Enable with the --DEBUG command line flag.
// tslint:disable-next-line:no-any
export function log(...args: any[]): void {
- if (debug) {
- console.log(...args);
+ if (logDebug) {
+ console.log("DEBUG JS -", ...args);
}
}