fix(daemon): include HOME in service env (#1214)
Thanks @ameno-. Co-authored-by: Ameno Osman <ameno.osman13@gmail.com>
This commit is contained in:
@@ -1,6 +1,10 @@
|
||||
import path from "node:path";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { buildMinimalServicePath, buildServiceEnvironment } from "./service-env.js";
|
||||
import {
|
||||
buildMinimalServicePath,
|
||||
buildNodeServiceEnvironment,
|
||||
buildServiceEnvironment,
|
||||
} from "./service-env.js";
|
||||
|
||||
describe("buildMinimalServicePath", () => {
|
||||
it("includes Homebrew + system dirs on macOS", () => {
|
||||
@@ -48,6 +52,7 @@ describe("buildServiceEnvironment", () => {
|
||||
port: 18789,
|
||||
token: "secret",
|
||||
});
|
||||
expect(env.HOME).toBe("/home/user");
|
||||
if (process.platform === "win32") {
|
||||
expect(env.PATH).toBe("");
|
||||
} else {
|
||||
@@ -75,3 +80,12 @@ describe("buildServiceEnvironment", () => {
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe("buildNodeServiceEnvironment", () => {
|
||||
it("passes through HOME for node services", () => {
|
||||
const env = buildNodeServiceEnvironment({
|
||||
env: { HOME: "/home/user" },
|
||||
});
|
||||
expect(env.HOME).toBe("/home/user");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -75,6 +75,7 @@ export function buildServiceEnvironment(params: {
|
||||
(process.platform === "darwin" ? resolveGatewayLaunchAgentLabel(profile) : undefined);
|
||||
const systemdUnit = `${resolveGatewaySystemdServiceName(profile)}.service`;
|
||||
return {
|
||||
HOME: env.HOME,
|
||||
PATH: buildMinimalServicePath({ env }),
|
||||
CLAWDBOT_PROFILE: profile,
|
||||
CLAWDBOT_STATE_DIR: env.CLAWDBOT_STATE_DIR,
|
||||
@@ -94,6 +95,7 @@ export function buildNodeServiceEnvironment(params: {
|
||||
}): Record<string, string | undefined> {
|
||||
const { env } = params;
|
||||
return {
|
||||
HOME: env.HOME,
|
||||
PATH: buildMinimalServicePath({ env }),
|
||||
CLAWDBOT_STATE_DIR: env.CLAWDBOT_STATE_DIR,
|
||||
CLAWDBOT_CONFIG_PATH: env.CLAWDBOT_CONFIG_PATH,
|
||||
|
||||
Reference in New Issue
Block a user