(
to: string,
from = process.cwd(),
{ preferAbsoluteIfShorter = true } = {},
)
| 21 | * directory. |
| 22 | */ |
| 23 | export function relative( |
| 24 | to: string, |
| 25 | from = process.cwd(), |
| 26 | { preferAbsoluteIfShorter = true } = {}, |
| 27 | ) { |
| 28 | let result = path.relative(from, to) |
| 29 | if (!result.startsWith('..')) { |
| 30 | result = `.${path.sep}${result}` |
| 31 | } |
| 32 | |
| 33 | if (preferAbsoluteIfShorter && result.length > to.length) { |
| 34 | return to |
| 35 | } |
| 36 | |
| 37 | return result |
| 38 | } |
| 39 | |
| 40 | /** |
| 41 | * Wrap `text` into multiple lines based on the `width`. |
no outgoing calls
no test coverage detected