diff --git a/libraries/deno-commons-mod.ts b/libraries/deno-commons-mod.ts index 3c6161d..ffc4dd9 100644 --- a/libraries/deno-commons-mod.ts +++ b/libraries/deno-commons-mod.ts @@ -4,7 +4,7 @@ import {assert} from "jsr:@std/assert/assert"; import {assertEquals} from "jsr:@std/assert"; import {decodeBase64, encodeBase64} from "jsr:@std/encoding/base64"; -import {dirname} from "https://deno.land/std@0.208.0/path/mod.ts"; +import {dirname, fromFileUrl} from "https://deno.land/std/path/mod.ts"; // reference: https://docs.deno.com/examples/hex_base64_encoding/ // import { decodeBase64, encodeBase64 } from "jsr:@std/encoding/base64"; @@ -589,6 +589,14 @@ export async function fetchWithTimeout( return response; } +export function getCurrentScriptFile(): string { + return fromFileUrl(import.meta.url); +} + +export function getCurrentScriptDirectory(): string { + return dirname(getCurrentScriptFile()); +} + Deno.test("isOn", () => { assertEquals(false, isOn(undefined)); assertEquals(false, isOn(""));