Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/__tests__/login.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import {describe, expect, it} from "vitest";

import {resolveLoginCodexPath} from "../login";

describe("resolveLoginCodexPath", () => {
it("uses the bundled Codex app-server when CODEX_PATH is absent", () => {
expect(resolveLoginCodexPath({})).toBeUndefined();
});

it("preserves an explicit CODEX_PATH override", () => {
expect(resolveLoginCodexPath({CODEX_PATH: "/opt/codex/bin/codex"})).toBe("/opt/codex/bin/codex");
});
});
6 changes: 5 additions & 1 deletion src/login.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ interface LoginOptions {
clientVersion?: string;
}

export function resolveLoginCodexPath(env: NodeJS.ProcessEnv = process.env): string | undefined {
return env["CODEX_PATH"];
}

function parseArgs(args: string[]): LoginOptions | null {
const options: LoginOptions = {};

Expand Down Expand Up @@ -63,7 +67,7 @@ Example:
}

async function login(options: LoginOptions): Promise<boolean> {
const codexPath = process.env["CODEX_PATH"] ?? "codex";
const codexPath = resolveLoginCodexPath();

logger.log("Starting Codex connection...");
const codexConnection = startCodexConnection(codexPath);
Expand Down