From 60f45cb8d544de3c77be90359bdce9ea98422040 Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Sun, 25 Jun 2023 16:58:29 -0400 Subject: [PATCH] fix: add __dirname compatibility --- src/index.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index c7c13d2..6abadfd 100644 --- a/src/index.ts +++ b/src/index.ts @@ -3,7 +3,14 @@ import { fileURLToPath } from "node:url"; import type { PresetAsset } from "presetter-types"; -const DIR = dirname(fileURLToPath(import.meta.url)); +let DIR: string; + +if (typeof __dirname === "undefined") { + // @ts-ignore + DIR = dirname(fileURLToPath(import.meta.url)); +} else { + DIR = __dirname; +} // paths to the template directory const TEMPLATES = resolve(DIR, "..", "templates");