diff options
Diffstat (limited to 'cli/js')
-rw-r--r-- | cli/js/lib.deno.unstable.d.ts | 3 | ||||
-rw-r--r-- | cli/js/ops/runtime.ts | 4 | ||||
-rw-r--r-- | cli/js/runtime_main.ts | 2 |
3 files changed, 9 insertions, 0 deletions
diff --git a/cli/js/lib.deno.unstable.d.ts b/cli/js/lib.deno.unstable.d.ts index aebd7f964..dc50416fc 100644 --- a/cli/js/lib.deno.unstable.d.ts +++ b/cli/js/lib.deno.unstable.d.ts @@ -1245,4 +1245,7 @@ declare namespace Deno { * Requires `allow-env` permission. */ export function hostname(): string; + + /** **UNSTABLE**: The URL of the file that was originally executed from the command-line. */ + export const mainModule: string; } diff --git a/cli/js/ops/runtime.ts b/cli/js/ops/runtime.ts index 632424327..70addf469 100644 --- a/cli/js/ops/runtime.ts +++ b/cli/js/ops/runtime.ts @@ -21,6 +21,10 @@ export function opStart(): Start { return sendSync("op_start"); } +export function opMainModule(): string { + return sendSync("op_main_module"); +} + export interface Metrics { opsDispatched: number; opsDispatchedSync: number; diff --git a/cli/js/runtime_main.ts b/cli/js/runtime_main.ts index 58405f673..25a6b0f93 100644 --- a/cli/js/runtime_main.ts +++ b/cli/js/runtime_main.ts @@ -9,6 +9,7 @@ import * as denoNs from "./deno.ts"; import * as denoUnstableNs from "./deno_unstable.ts"; +import { opMainModule } from "./ops/runtime.ts"; import { exit } from "./ops/os.ts"; import { readOnly, @@ -106,6 +107,7 @@ export function bootstrapMainRuntime(): void { if (unstableFlag) { Object.defineProperties(globalThis, unstableMethods); Object.defineProperties(globalThis, unstableProperties); + Object.defineProperty(denoNs, "mainModule", getterOnly(opMainModule)); Object.assign(denoNs, denoUnstableNs); } |