mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-07 20:41:24 +00:00
chore: Enable "curly" rule to avoid single-statement if confusion/errors.
This commit is contained in:
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user