refactor: move dir check to separate file to be dynamically loaded if esm
This commit is contained in:
parent
60f45cb8d5
commit
847ade399f
|
@ -1,13 +1,11 @@
|
||||||
import { dirname, resolve } from "node:path";
|
import { resolve } from "node:path";
|
||||||
import { fileURLToPath } from "node:url";
|
|
||||||
|
|
||||||
import type { PresetAsset } from "presetter-types";
|
import type { PresetAsset } from "presetter-types";
|
||||||
|
|
||||||
let DIR: string;
|
let DIR: string;
|
||||||
|
|
||||||
if (typeof __dirname === "undefined") {
|
if (typeof __dirname === "undefined") {
|
||||||
// @ts-ignore
|
DIR = (await import("./path.js")).default();
|
||||||
DIR = dirname(fileURLToPath(import.meta.url));
|
|
||||||
} else {
|
} else {
|
||||||
DIR = __dirname;
|
DIR = __dirname;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
import { dirname } from "node:path";
|
||||||
|
import { fileURLToPath } from "node:url";
|
||||||
|
|
||||||
|
export default function () {
|
||||||
|
return dirname(fileURLToPath(import.meta.url));
|
||||||
|
}
|
Loading…
Reference in New Issue