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

pathExpansion.ts

16 lines524 Bytes

1// @effect-diagnostics nodeBuiltinImport:off
2import * as NodePath from "node:path";
3​
4/**
5 * Spawned processes don't get shell expansion, so env vars like
6 * `CODEX_HOME=~/.codex-work` would be passed verbatim and treated as relative
7 * paths by the receiver.
8 */
9export function expandHomePath(value: string, home: string): string {
10 if (!value) return value;
11 if (value === "~") return home;
12 if (value.startsWith("~/") || value.startsWith("~\\")) {
13 return NodePath.join(home, value.slice(2));
14 }
15 return value;