mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 05:51:24 +00:00
chore: Enable "curly" rule to avoid single-statement if confusion/errors.
This commit is contained in:
@@ -28,7 +28,9 @@ const formatLine = (label: string, value: string) => {
|
||||
|
||||
function resolveLaunchAgentLabel(args?: { env?: Record<string, string | undefined> }): string {
|
||||
const envLabel = args?.env?.OPENCLAW_LAUNCHD_LABEL?.trim();
|
||||
if (envLabel) return envLabel;
|
||||
if (envLabel) {
|
||||
return envLabel;
|
||||
}
|
||||
return resolveGatewayLaunchAgentLabel(args?.env?.OPENCLAW_PROFILE);
|
||||
}
|
||||
|
||||
@@ -130,7 +132,9 @@ async function execLaunchctl(
|
||||
}
|
||||
|
||||
function resolveGuiDomain(): string {
|
||||
if (typeof process.getuid !== "function") return "gui/501";
|
||||
if (typeof process.getuid !== "function") {
|
||||
return "gui/501";
|
||||
}
|
||||
return `gui/${process.getuid()}`;
|
||||
}
|
||||
|
||||
@@ -145,19 +149,27 @@ export function parseLaunchctlPrint(output: string): LaunchctlPrintInfo {
|
||||
const entries = parseKeyValueOutput(output, "=");
|
||||
const info: LaunchctlPrintInfo = {};
|
||||
const state = entries.state;
|
||||
if (state) info.state = state;
|
||||
if (state) {
|
||||
info.state = state;
|
||||
}
|
||||
const pidValue = entries.pid;
|
||||
if (pidValue) {
|
||||
const pid = Number.parseInt(pidValue, 10);
|
||||
if (Number.isFinite(pid)) info.pid = pid;
|
||||
if (Number.isFinite(pid)) {
|
||||
info.pid = pid;
|
||||
}
|
||||
}
|
||||
const exitStatusValue = entries["last exit status"];
|
||||
if (exitStatusValue) {
|
||||
const status = Number.parseInt(exitStatusValue, 10);
|
||||
if (Number.isFinite(status)) info.lastExitStatus = status;
|
||||
if (Number.isFinite(status)) {
|
||||
info.lastExitStatus = status;
|
||||
}
|
||||
}
|
||||
const exitReason = entries["last exit reason"];
|
||||
if (exitReason) info.lastExitReason = exitReason;
|
||||
if (exitReason) {
|
||||
info.lastExitReason = exitReason;
|
||||
}
|
||||
return info;
|
||||
}
|
||||
|
||||
@@ -175,7 +187,9 @@ export async function isLaunchAgentListed(args: {
|
||||
}): Promise<boolean> {
|
||||
const label = resolveLaunchAgentLabel({ env: args.env });
|
||||
const res = await execLaunchctl(["list"]);
|
||||
if (res.code !== 0) return false;
|
||||
if (res.code !== 0) {
|
||||
return false;
|
||||
}
|
||||
return res.stdout.split(/\r?\n/).some((line) => line.trim().split(/\s+/).at(-1) === label);
|
||||
}
|
||||
|
||||
@@ -275,7 +289,9 @@ export async function uninstallLegacyLaunchAgents({
|
||||
}): Promise<LegacyLaunchAgent[]> {
|
||||
const domain = resolveGuiDomain();
|
||||
const agents = await findLegacyLaunchAgents(env);
|
||||
if (agents.length === 0) return agents;
|
||||
if (agents.length === 0) {
|
||||
return agents;
|
||||
}
|
||||
|
||||
const home = resolveHomeDir(env);
|
||||
const trashDir = path.join(home, ".Trash");
|
||||
|
||||
Reference in New Issue
Block a user