mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-24 21:08:38 +00:00
refactor: share daemon install cli setup
This commit is contained in:
@@ -84,8 +84,28 @@ vi.mock("../../commands/daemon-install-helpers.js", () => ({
|
||||
|
||||
vi.mock("./shared.js", () => ({
|
||||
parsePort: parsePortMock,
|
||||
createDaemonInstallActionContext: (jsonFlag: unknown) => {
|
||||
const json = Boolean(jsonFlag);
|
||||
return {
|
||||
json,
|
||||
stdout: process.stdout,
|
||||
warnings: actionState.warnings,
|
||||
emit: (payload: DaemonActionResponse) => {
|
||||
actionState.emitted.push(payload);
|
||||
},
|
||||
fail: (message: string, hints?: string[]) => {
|
||||
actionState.failed.push({ message, hints });
|
||||
},
|
||||
};
|
||||
},
|
||||
failIfNixDaemonInstallMode: (fail: (message: string, hints?: string[]) => void) => {
|
||||
if (!resolveIsNixModeMock()) {
|
||||
return false;
|
||||
}
|
||||
fail("Nix mode detected; service install is disabled.");
|
||||
return true;
|
||||
},
|
||||
}));
|
||||
|
||||
vi.mock("../../commands/daemon-runtime.js", () => ({
|
||||
DEFAULT_GATEWAY_DAEMON_RUNTIME: "node",
|
||||
isGatewayDaemonRuntime: isGatewayDaemonRuntimeMock,
|
||||
@@ -97,16 +117,6 @@ vi.mock("../../daemon/service.js", () => ({
|
||||
|
||||
vi.mock("./response.js", () => ({
|
||||
buildDaemonServiceSnapshot: vi.fn(),
|
||||
createDaemonActionContext: vi.fn(() => ({
|
||||
stdout: process.stdout,
|
||||
warnings: actionState.warnings,
|
||||
emit: (payload: DaemonActionResponse) => {
|
||||
actionState.emitted.push(payload);
|
||||
},
|
||||
fail: (message: string, hints?: string[]) => {
|
||||
actionState.failed.push({ message, hints });
|
||||
},
|
||||
})),
|
||||
installDaemonServiceAndEmit: installDaemonServiceAndEmitMock,
|
||||
}));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user