From 22d9487d191efb858be766830c8702875483e780 Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Sun, 25 Jun 2023 17:11:52 -0400 Subject: [PATCH] refactor: need to move dir check and TEMPLATES const inside function --- src/index.ts | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/index.ts b/src/index.ts index da8cb5b..4c168e6 100644 --- a/src/index.ts +++ b/src/index.ts @@ -2,16 +2,7 @@ import { resolve } from "node:path"; import type { PresetAsset } from "presetter-types"; -let DIR: string; - -if (typeof __dirname === "undefined") { - DIR = (await import("./path.js")).default(); -} else { - DIR = __dirname; -} - // paths to the template directory -const TEMPLATES = resolve(DIR, "..", "templates"); export const DEFAULT_VARIABLE = { source: "src", }; @@ -21,6 +12,16 @@ export const DEFAULT_VARIABLE = { * @returns list of preset templates */ export default async function (): Promise { + let DIR: string; + + if (typeof __dirname === "undefined") { + DIR = (await import("./path.js")).default(); + } else { + DIR = __dirname; + } + + const TEMPLATES = resolve(DIR, "..", "templates"); + return { extends: ["presetter-preset-strict"], template: {