chore: Enable "curly" rule to avoid single-statement if confusion/errors.
This commit is contained in:
@@ -21,9 +21,13 @@ const DEV_TEMPLATE_DIR = path.resolve(
|
||||
async function loadDevTemplate(name: string, fallback: string): Promise<string> {
|
||||
try {
|
||||
const raw = await fs.promises.readFile(path.join(DEV_TEMPLATE_DIR, name), "utf-8");
|
||||
if (!raw.startsWith("---")) return raw;
|
||||
if (!raw.startsWith("---")) {
|
||||
return raw;
|
||||
}
|
||||
const endIndex = raw.indexOf("\n---", 3);
|
||||
if (endIndex === -1) return raw;
|
||||
if (endIndex === -1) {
|
||||
return raw;
|
||||
}
|
||||
return raw.slice(endIndex + "\n---".length).replace(/^\s+/, "");
|
||||
} catch {
|
||||
return fallback;
|
||||
@@ -33,7 +37,9 @@ async function loadDevTemplate(name: string, fallback: string): Promise<string>
|
||||
const resolveDevWorkspaceDir = (env: NodeJS.ProcessEnv = process.env): string => {
|
||||
const baseDir = resolveDefaultAgentWorkspaceDir(env, os.homedir);
|
||||
const profile = env.OPENCLAW_PROFILE?.trim().toLowerCase();
|
||||
if (profile === "dev") return baseDir;
|
||||
if (profile === "dev") {
|
||||
return baseDir;
|
||||
}
|
||||
return `${baseDir}-${DEV_AGENT_WORKSPACE_SUFFIX}`;
|
||||
};
|
||||
|
||||
@@ -45,7 +51,9 @@ async function writeFileIfMissing(filePath: string, content: string) {
|
||||
});
|
||||
} catch (err) {
|
||||
const anyErr = err as { code?: string };
|
||||
if (anyErr.code !== "EEXIST") throw err;
|
||||
if (anyErr.code !== "EEXIST") {
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,7 +100,9 @@ export async function ensureDevGatewayConfig(opts: { reset?: boolean }) {
|
||||
const io = createConfigIO();
|
||||
const configPath = io.configPath;
|
||||
const configExists = fs.existsSync(configPath);
|
||||
if (!opts.reset && configExists) return;
|
||||
if (!opts.reset && configExists) {
|
||||
return;
|
||||
}
|
||||
|
||||
await writeConfigFile({
|
||||
gateway: {
|
||||
|
||||
Reference in New Issue
Block a user