mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 04:47:39 +00:00
fix(imessage): prevent rpc spawn in tests
This commit is contained in:
@@ -37,6 +37,14 @@ type PendingRequest = {
|
||||
timer?: NodeJS.Timeout;
|
||||
};
|
||||
|
||||
function isTestEnv(): boolean {
|
||||
if (process.env.NODE_ENV === "test") {
|
||||
return true;
|
||||
}
|
||||
const vitest = process.env.VITEST?.trim().toLowerCase();
|
||||
return Boolean(vitest);
|
||||
}
|
||||
|
||||
export class IMessageRpcClient {
|
||||
private readonly cliPath: string;
|
||||
private readonly dbPath?: string;
|
||||
@@ -63,6 +71,9 @@ export class IMessageRpcClient {
|
||||
if (this.child) {
|
||||
return;
|
||||
}
|
||||
if (isTestEnv()) {
|
||||
throw new Error("Refusing to start imsg rpc in test environment; mock iMessage RPC client");
|
||||
}
|
||||
const args = ["rpc"];
|
||||
if (this.dbPath) {
|
||||
args.push("--db", this.dbPath);
|
||||
|
||||
Reference in New Issue
Block a user