mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 17:04:32 +00:00
chore: Enable "curly" rule to avoid single-statement if confusion/errors.
This commit is contained in:
@@ -13,15 +13,21 @@ export type ResolveBonjourCliPathOptions = {
|
||||
|
||||
export function formatBonjourInstanceName(displayName: string) {
|
||||
const trimmed = displayName.trim();
|
||||
if (!trimmed) return "OpenClaw";
|
||||
if (/openclaw/i.test(trimmed)) return trimmed;
|
||||
if (!trimmed) {
|
||||
return "OpenClaw";
|
||||
}
|
||||
if (/openclaw/i.test(trimmed)) {
|
||||
return trimmed;
|
||||
}
|
||||
return `${trimmed} (OpenClaw)`;
|
||||
}
|
||||
|
||||
export function resolveBonjourCliPath(opts: ResolveBonjourCliPathOptions = {}): string | undefined {
|
||||
const env = opts.env ?? process.env;
|
||||
const envPath = env.OPENCLAW_CLI_PATH?.trim();
|
||||
if (envPath) return envPath;
|
||||
if (envPath) {
|
||||
return envPath;
|
||||
}
|
||||
|
||||
const statSync = opts.statSync ?? fs.statSync;
|
||||
const isFile = (candidate: string) => {
|
||||
@@ -35,7 +41,9 @@ export function resolveBonjourCliPath(opts: ResolveBonjourCliPathOptions = {}):
|
||||
const execPath = opts.execPath ?? process.execPath;
|
||||
const execDir = path.dirname(execPath);
|
||||
const siblingCli = path.join(execDir, "openclaw");
|
||||
if (isFile(siblingCli)) return siblingCli;
|
||||
if (isFile(siblingCli)) {
|
||||
return siblingCli;
|
||||
}
|
||||
|
||||
const argv = opts.argv ?? process.argv;
|
||||
const argvPath = argv[1];
|
||||
@@ -45,9 +53,13 @@ export function resolveBonjourCliPath(opts: ResolveBonjourCliPathOptions = {}):
|
||||
|
||||
const cwd = opts.cwd ?? process.cwd();
|
||||
const distCli = path.join(cwd, "dist", "index.js");
|
||||
if (isFile(distCli)) return distCli;
|
||||
if (isFile(distCli)) {
|
||||
return distCli;
|
||||
}
|
||||
const binCli = path.join(cwd, "bin", "openclaw");
|
||||
if (isFile(binCli)) return binCli;
|
||||
if (isFile(binCli)) {
|
||||
return binCli;
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
@@ -60,8 +72,12 @@ export async function resolveTailnetDnsHint(opts?: {
|
||||
const env = opts?.env ?? process.env;
|
||||
const envRaw = env.OPENCLAW_TAILNET_DNS?.trim();
|
||||
const envValue = envRaw && envRaw.length > 0 ? envRaw.replace(/\.$/, "") : "";
|
||||
if (envValue) return envValue;
|
||||
if (opts?.enabled === false) return undefined;
|
||||
if (envValue) {
|
||||
return envValue;
|
||||
}
|
||||
if (opts?.enabled === false) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const exec =
|
||||
opts?.exec ??
|
||||
|
||||
Reference in New Issue
Block a user