mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 04:51:25 +00:00
chore: Enable "curly" rule to avoid single-statement if confusion/errors.
This commit is contained in:
@@ -35,9 +35,13 @@ const TEMPLATE_DIR = path.resolve(
|
||||
);
|
||||
|
||||
function stripFrontMatter(content: string): string {
|
||||
if (!content.startsWith("---")) return content;
|
||||
if (!content.startsWith("---")) {
|
||||
return content;
|
||||
}
|
||||
const endIndex = content.indexOf("\n---", 3);
|
||||
if (endIndex === -1) return content;
|
||||
if (endIndex === -1) {
|
||||
return content;
|
||||
}
|
||||
const start = endIndex + "\n---".length;
|
||||
let trimmed = content.slice(start);
|
||||
trimmed = trimmed.replace(/^\s+/, "");
|
||||
@@ -82,7 +86,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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,9 +111,15 @@ async function isGitAvailable(): Promise<boolean> {
|
||||
}
|
||||
|
||||
async function ensureGitRepo(dir: string, isBrandNewWorkspace: boolean) {
|
||||
if (!isBrandNewWorkspace) return;
|
||||
if (await hasGitRepo(dir)) return;
|
||||
if (!(await isGitAvailable())) return;
|
||||
if (!isBrandNewWorkspace) {
|
||||
return;
|
||||
}
|
||||
if (await hasGitRepo(dir)) {
|
||||
return;
|
||||
}
|
||||
if (!(await isGitAvailable())) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
await runCommandWithTimeout(["git", "init"], { cwd: dir, timeoutMs: 10_000 });
|
||||
} catch {
|
||||
@@ -132,7 +144,9 @@ export async function ensureAgentWorkspace(params?: {
|
||||
const dir = resolveUserPath(rawDir);
|
||||
await fs.mkdir(dir, { recursive: true });
|
||||
|
||||
if (!params?.ensureBootstrapFiles) return { dir };
|
||||
if (!params?.ensureBootstrapFiles) {
|
||||
return { dir };
|
||||
}
|
||||
|
||||
const agentsPath = path.join(dir, DEFAULT_AGENTS_FILENAME);
|
||||
const soulPath = path.join(dir, DEFAULT_SOUL_FILENAME);
|
||||
@@ -205,7 +219,9 @@ async function resolveMemoryBootstrapEntries(
|
||||
// optional
|
||||
}
|
||||
}
|
||||
if (entries.length <= 1) return entries;
|
||||
if (entries.length <= 1) {
|
||||
return entries;
|
||||
}
|
||||
|
||||
const seen = new Set<string>();
|
||||
const deduped: Array<{ name: WorkspaceBootstrapFileName; filePath: string }> = [];
|
||||
@@ -214,7 +230,9 @@ async function resolveMemoryBootstrapEntries(
|
||||
try {
|
||||
key = await fs.realpath(entry.filePath);
|
||||
} catch {}
|
||||
if (seen.has(key)) continue;
|
||||
if (seen.has(key)) {
|
||||
continue;
|
||||
}
|
||||
seen.add(key);
|
||||
deduped.push(entry);
|
||||
}
|
||||
@@ -283,6 +301,8 @@ export function filterBootstrapFilesForSession(
|
||||
files: WorkspaceBootstrapFile[],
|
||||
sessionKey?: string,
|
||||
): WorkspaceBootstrapFile[] {
|
||||
if (!sessionKey || !isSubagentSessionKey(sessionKey)) return files;
|
||||
if (!sessionKey || !isSubagentSessionKey(sessionKey)) {
|
||||
return files;
|
||||
}
|
||||
return files.filter((file) => SUBAGENT_BOOTSTRAP_ALLOWLIST.has(file.name));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user