chore: Enable "curly" rule to avoid single-statement if confusion/errors.

This commit is contained in:
cpojer
2026-01-31 16:19:20 +09:00
parent 009b16fab8
commit 5ceff756e1
1266 changed files with 27871 additions and 9393 deletions

View File

@@ -24,7 +24,9 @@ function takeValue(
}
export function parseCliProfileArgs(argv: string[]): CliProfileParseResult {
if (argv.length < 2) return { ok: true, profile: null, argv };
if (argv.length < 2) {
return { ok: true, profile: null, argv };
}
const out: string[] = argv.slice(0, 2);
let profile: string | null = null;
@@ -34,7 +36,9 @@ export function parseCliProfileArgs(argv: string[]): CliProfileParseResult {
const args = argv.slice(2);
for (let i = 0; i < args.length; i += 1) {
const arg = args[i];
if (arg === undefined) continue;
if (arg === undefined) {
continue;
}
if (sawCommand) {
out.push(arg);
@@ -56,8 +60,12 @@ export function parseCliProfileArgs(argv: string[]): CliProfileParseResult {
}
const next = args[i + 1];
const { value, consumedNext } = takeValue(arg, next);
if (consumedNext) i += 1;
if (!value) return { ok: false, error: "--profile requires a value" };
if (consumedNext) {
i += 1;
}
if (!value) {
return { ok: false, error: "--profile requires a value" };
}
if (!isValidProfileName(value)) {
return {
ok: false,
@@ -93,13 +101,17 @@ export function applyCliProfileEnv(params: {
const env = params.env ?? (process.env as Record<string, string | undefined>);
const homedir = params.homedir ?? os.homedir;
const profile = params.profile.trim();
if (!profile) return;
if (!profile) {
return;
}
// Convenience only: fill defaults, never override explicit env values.
env.OPENCLAW_PROFILE = profile;
const stateDir = env.OPENCLAW_STATE_DIR?.trim() || resolveProfileStateDir(profile, homedir);
if (!env.OPENCLAW_STATE_DIR?.trim()) env.OPENCLAW_STATE_DIR = stateDir;
if (!env.OPENCLAW_STATE_DIR?.trim()) {
env.OPENCLAW_STATE_DIR = stateDir;
}
if (!env.OPENCLAW_CONFIG_PATH?.trim()) {
env.OPENCLAW_CONFIG_PATH = path.join(stateDir, "openclaw.json");