@bitkyc08/opencodex
Version:
Universal provider proxy for OpenAI Codex & Claude Code — use any LLM with Codex CLI/App/SDK and Claude Code
19 lines (17 loc) • 753 B
text/typescript
import { mkdirSync } from "node:fs";
import { dirname } from "node:path";
import { codexHomeIsAbsent } from "./codex-home-owner";
/**
* Create a proven-missing home before a writer that has always created it.
* A failed request keeps the directory: a pathname-based removal cannot prove it
* still names the directory this request created, so deleting it could remove a
* concurrent replacement. An empty home is what Codex itself would create.
*/
export function prepareCodexHome(home: string, mode?: number): void {
if (!codexHomeIsAbsent(home)) return;
mkdirSync(dirname(home), { recursive: true, mode });
try { mkdirSync(home, { mode }); }
catch (error) {
if ((error as NodeJS.ErrnoException).code !== "EEXIST") throw error;
}
}