Function: relative()
ts
function relative(from, to): string;根据当前工作目录,计算从 from 到 to 的相对路径。
Parameters
| Parameter | Type | Description |
|---|---|---|
from | string | 源路径 |
to | string | 目标路径 |
Returns
string
相对路径
Example
ts
relative('/data/orandea/test/aaa', '/data/orandea/impl/bbb') // => '../../impl/bbb'
relative('/foo/bar/baz', '/foo/bar/baz') // => ''
relative('/foo/bar/baz', '/foo/bar/baz/') // => ''
relative('/foo/bar/baz', '/foo/bar/baz/file.txt') // => 'file.txt'Since
1.0.0