refactor: need to move dir check and TEMPLATES const inside function

This commit is contained in:
Derrick Hammer 2023-06-25 17:11:52 -04:00
parent bdd2b66725
commit 22d9487d19
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 10 additions and 9 deletions

View File

@ -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<PresetAsset> {
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: {