t-comm
Version:
专业、稳定、纯粹的工具库
32 lines (25 loc) • 748 B
JavaScript
;
Object.defineProperty(exports, '__esModule', { value: true });
var path = require('path');
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
var path__default = /*#__PURE__*/_interopDefaultLegacy(path);
/**
* A引用B时,拿引用路径
* @param pathA 路径A
* @param pathB 路径B
* @returns 相对路径
* @example
* ```ts
* getRelativePath('a', 'b');
*
* // './b'
* ```
*/
function getRelativePath(pathA, pathB) {
var result = path__default["default"].relative(path__default["default"].join(pathA, '..'), pathB);
if (!result.startsWith('.')) {
return "./".concat(result);
}
return result;
}
exports.getRelativePath = getRelativePath;