UNPKG

@intlayer/chokidar

Version:

Uses chokidar to scan and build Intlayer declaration files into dictionaries based on Intlayer configuration.

20 lines (18 loc) 962 B
import { dirname, isAbsolute, normalize, resolve } from "node:path"; //#region src/utils/resolveRelativePath.ts const resolveRelativePath = (path, sourcePath, baseDir) => { if (isAbsolute(path)) { const normalizedResult = normalize(path); const normalizedBaseDir = normalize(baseDir); if (path.startsWith("/") && !normalizedResult.startsWith(normalizedBaseDir)) { const relativeToBase = resolve(baseDir, path.substring(1)); if (!path.startsWith("/usr/") && !path.startsWith("/etc/") && !path.startsWith("/var/") && !path.startsWith("/home/") && !path.startsWith("/Users/") && !path.startsWith("/tmp/") && !path.startsWith("/private/") && !path.startsWith("/opt/")) return relativeToBase; } return normalizedResult; } if (path.startsWith("./") || path.startsWith("../")) return resolve(dirname(sourcePath), path); return resolve(baseDir, path); }; //#endregion export { resolveRelativePath }; //# sourceMappingURL=resolveRelativePath.mjs.map