import path from "path"; import nodeUrl from "url"; /** * Получает URL из `import.meta` * @param importMetaUrl{String} * @returns {string} * @example * import { getDir } from "@delement/ui/utils/node"; * * const currentDir = getDir(import.meta.url); */ const getDir = (importMetaUrl: ImportMeta["url"] | string): string => { if (typeof nodeUrl.fileURLToPath === "function") { const __filename = nodeUrl.fileURLToPath(importMetaUrl); return path.dirname(__filename); } else { return new URL(".", importMetaUrl).pathname; } }; export { getDir, };