UNPKG

t-comm

Version:

专业、稳定、纯粹的工具库

24 lines (21 loc) 463 B
import { getPath } from '../nodejs/path.mjs'; /** * A引用B时,拿引用路径 * @param pathA 路径A * @param pathB 路径B * @returns 相对路径 * @example * ```ts * getRelativePath('a', 'b'); * * // './b' * ``` */ function getRelativePath(pathA, pathB) { var result = getPath().relative(getPath().join(pathA, '..'), pathB); if (!result.startsWith('.')) { return "./".concat(result); } return result; } export { getRelativePath };