Skip to content

Commit 99f6455

Browse files
committed
fix(server): restore PR detection without HOME
1 parent 9dd425b commit 99f6455

2 files changed

Lines changed: 38 additions & 2 deletions

File tree

‎apps/server/src/os-jank.test.ts‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { assert, it } from "@effect/vitest";
2+
3+
import { hydratePosixHome } from "./os-jank.ts";
4+
5+
it("hydrates HOME for minimal service environments", () => {
6+
const env: NodeJS.ProcessEnv = {};
7+
8+
hydratePosixHome(env, "/home/service-user");
9+
10+
assert.equal(env.HOME, "/home/service-user");
11+
});
12+
13+
it("hydrates a blank HOME value", () => {
14+
const env: NodeJS.ProcessEnv = { HOME: " " };
15+
16+
hydratePosixHome(env, "/home/service-user");
17+
18+
assert.equal(env.HOME, "/home/service-user");
19+
});
20+
21+
it("preserves an explicitly configured HOME", () => {
22+
const env: NodeJS.ProcessEnv = { HOME: "/custom/home" };
23+
24+
hydratePosixHome(env, "/home/service-user");
25+
26+
assert.equal(env.HOME, "/custom/home");
27+
});

‎apps/server/src/os-jank.ts‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@ function hydratePosixPath(env: NodeJS.ProcessEnv, platform: NodeJS.Platform): vo
3636
}
3737
}
3838

39+
export function hydratePosixHome(env: NodeJS.ProcessEnv, homeDir = NodeOS.homedir()): void {
40+
if ((env.HOME?.trim() ?? "").length === 0 && homeDir.length > 0) {
41+
env.HOME = homeDir;
42+
}
43+
}
44+
3945
export const fixPath = Effect.fn("fixPath")(function* (): Effect.fn.Return<
4046
void,
4147
never,
@@ -63,10 +69,13 @@ export const fixPath = Effect.fn("fixPath")(function* (): Effect.fn.Return<
6369

6470
if (platform !== "darwin" && platform !== "linux") return;
6571

66-
yield* Effect.sync(() => hydratePosixPath(env, platform)).pipe(
72+
yield* Effect.sync(() => {
73+
hydratePosixHome(env);
74+
hydratePosixPath(env, platform);
75+
}).pipe(
6776
Effect.catchDefect((defect) =>
6877
Effect.sync(() => {
69-
logPathHydrationWarning("Failed to hydrate PATH from the user environment.", defect);
78+
logPathHydrationWarning("Failed to hydrate the user environment.", defect);
7079
}),
7180
),
7281
);

0 commit comments

Comments
 (0)