UNPKG

@apistudio/apim-cli

Version:

CLI for API Management Products

24 lines (19 loc) 747 B
/** * Lazy-loaded parent directory to avoid immediate execution of Node.js-specific imports. * This prevents bundling issues in browser-based applications. */ let _parentDir: string | null = null; /** * Get the directory name of the current module. * Lazy loads Node.js dependencies (url, path) only when needed. */ export async function getParentDir(): Promise<string> { if (_parentDir === null) { // Lazy import to avoid bundling Node.js modules in browser apps const { fileURLToPath } = await import('url'); const path = await import('path'); const currentFile = fileURLToPath(import.meta.url); _parentDir = path.resolve(path.dirname(currentFile), '../src'); } return _parentDir; }