runtime.tsx 337 B

123456789
  1. import path from "path"
  2. export function abbreviateHome(input: string, home: string) {
  3. if (!home) return input
  4. const relative = path.relative(home, input)
  5. if (relative === "") return "~"
  6. if (relative === ".." || relative.startsWith(".." + path.sep) || path.isAbsolute(relative)) return input
  7. return "~" + path.sep + relative
  8. }