function isDenoCompiledBinary
isDenoCompiledBinary(
hasDeno?: boolean,
execPath?: string
): boolean

True when running inside a deno compiled binary (vs deno run script.ts or plain Node). Detection is on process.execPath: under deno run it ends with deno (or deno.exe on Windows); inside a compiled binary it's the user's binary name. Deno.mainModule looked tempting but is also a file: URL in compiled binaries (a virtual path under /tmp/deno-compile-<name>/), so it can't differentiate the two.

isDenoCompiledBinary(true, '/usr/bin/deno'); // false — plain `deno run`
isDenoCompiledBinary(true, '/usr/local/bin/qunitx'); // true — a compiled binary
isDenoCompiledBinary(false, '/usr/bin/node'); // false — not Deno at all

Parameters

optional
hasDeno: boolean
optional
execPath: string = [process.execPath]

Return Type

boolean

Usage

import { isDenoCompiledBinary } from "lib/utils/run-user-module.ts";