Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

pathExpansion.ts

12 lines434 Bytes

1// @effect-diagnostics nodeBuiltinImport:off
2import * as NodePath from "node:path";
3​
4// Spawned processes lack shell expansion and would treat literal ~/ paths as relative.
5export function expandHomePath(value: string, home: string): string {
6 if (!value) return value;
7 if (value === "~") return home;
8 if (value.startsWith("~/") || value.startsWith("~\\")) {
9 return NodePath.join(home, value.slice(2));
10 }
11 return value;