t-comm
Version:
专业、稳定、纯粹的工具库
28 lines (23 loc) • 583 B
JavaScript
;
Object.defineProperty(exports, '__esModule', { value: true });
var nodejs_path = require('../nodejs/path.js');
/**
* A引用B时,拿引用路径
* @param pathA 路径A
* @param pathB 路径B
* @returns 相对路径
* @example
* ```ts
* getRelativePath('a', 'b');
*
* // './b'
* ```
*/
function getRelativePath(pathA, pathB) {
var result = nodejs_path.getPath().relative(nodejs_path.getPath().join(pathA, '..'), pathB);
if (!result.startsWith('.')) {
return "./".concat(result);
}
return result;
}
exports.getRelativePath = getRelativePath;