Files
t3code/apps/server/src/os-jank.ts
T
Guilherme Barros e1c33dcd33 Fix Fish shell PATH detection and clean up lint warnings (#323)
* Fix Fish shell PATH detection for Codex

* refactor(provider): resolve lint warnings in provider layers

* refactor(terminal): simplify thread lock release initialization

* test(git): simplify fetch release callback initialization
2026-03-07 02:14:30 -08:00

37 lines
1010 B
TypeScript

import * as OS from "node:os";
import { Effect, Path } from "effect";
import { readPathFromLoginShell } from "@t3tools/shared/shell";
export function fixPath(): void {
if (process.platform !== "darwin") return;
try {
const shell = process.env.SHELL ?? "/bin/zsh";
const result = readPathFromLoginShell(shell);
if (result) {
process.env.PATH = result;
}
} catch {
// Silently ignore — keep default PATH
}
}
export const expandHomePath = Effect.fn(function* (input: string) {
const { join } = yield* Path.Path;
if (input === "~") {
return OS.homedir();
}
if (input.startsWith("~/") || input.startsWith("~\\")) {
return join(OS.homedir(), input.slice(2));
}
return input;
});
export const resolveStateDir = Effect.fn(function* (raw: string | undefined) {
const { join, resolve } = yield* Path.Path;
if (!raw || raw.trim().length === 0) {
return join(OS.homedir(), ".t3", "userdata");
}
return resolve(yield* expandHomePath(raw.trim()));
});