MCPcopy
hub / github.com/tailwindlabs/tailwindcss / relative

Function relative

packages/@tailwindcss-cli/src/utils/renderer.ts:23–38  ·  view source on GitHub ↗
(
  to: string,
  from = process.cwd(),
  { preferAbsoluteIfShorter = true } = {},
)

Source from the content-addressed store, hash-verified

21 * directory.
22 */
23export 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`.

Callers 2

renderer.test.tsFile · 0.90
OnceFunction · 0.50

Calls

no outgoing calls

Tested by

no test coverage detected