refactor: need to move dir check and TEMPLATES const inside function
This commit is contained in:
parent
bdd2b66725
commit
22d9487d19
19
src/index.ts
19
src/index.ts
|
@ -2,16 +2,7 @@ import { resolve } from "node:path";
|
||||||
|
|
||||||
import type { PresetAsset } from "presetter-types";
|
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
|
// paths to the template directory
|
||||||
const TEMPLATES = resolve(DIR, "..", "templates");
|
|
||||||
export const DEFAULT_VARIABLE = {
|
export const DEFAULT_VARIABLE = {
|
||||||
source: "src",
|
source: "src",
|
||||||
};
|
};
|
||||||
|
@ -21,6 +12,16 @@ export const DEFAULT_VARIABLE = {
|
||||||
* @returns list of preset templates
|
* @returns list of preset templates
|
||||||
*/
|
*/
|
||||||
export default async function (): Promise<PresetAsset> {
|
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 {
|
return {
|
||||||
extends: ["presetter-preset-strict"],
|
extends: ["presetter-preset-strict"],
|
||||||
template: {
|
template: {
|
||||||
|
|
Loading…
Reference in New Issue