mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-19 11:48:38 +00:00
chore: Enable linting in scripts.
This commit is contained in:
@@ -19,7 +19,9 @@ function runGitCommand(args, options = {}) {
|
||||
}
|
||||
|
||||
function splitNullDelimited(value) {
|
||||
if (!value) return [];
|
||||
if (!value) {
|
||||
return [];
|
||||
}
|
||||
const text = String(value);
|
||||
return text.split("\0").filter(Boolean);
|
||||
}
|
||||
@@ -44,7 +46,9 @@ function findPartiallyStagedFiles(stagedFiles, unstagedFiles) {
|
||||
}
|
||||
|
||||
function filterOutPartialTargets(targets, partialTargets) {
|
||||
if (partialTargets.length === 0) return targets;
|
||||
if (partialTargets.length === 0) {
|
||||
return targets;
|
||||
}
|
||||
const partial = new Set(partialTargets.map(normalizeGitPath));
|
||||
return targets.filter((filePath) => !partial.has(normalizeGitPath(filePath)));
|
||||
}
|
||||
@@ -66,7 +70,9 @@ function resolveOxfmtCommand(repoRoot) {
|
||||
|
||||
function getGitPaths(args, repoRoot) {
|
||||
const result = runGitCommand(args, { cwd: repoRoot });
|
||||
if (result.status !== 0) return [];
|
||||
if (result.status !== 0) {
|
||||
return [];
|
||||
}
|
||||
return splitNullDelimited(result.stdout ?? "");
|
||||
}
|
||||
|
||||
@@ -79,7 +85,9 @@ function formatFiles(repoRoot, oxfmt, files) {
|
||||
}
|
||||
|
||||
function stageFiles(repoRoot, files) {
|
||||
if (files.length === 0) return true;
|
||||
if (files.length === 0) {
|
||||
return true;
|
||||
}
|
||||
const result = runGitCommand(["add", "--", ...files], { cwd: repoRoot, stdio: "inherit" });
|
||||
return result.status === 0;
|
||||
}
|
||||
@@ -91,7 +99,9 @@ function main() {
|
||||
repoRoot,
|
||||
);
|
||||
const targets = filterOxfmtTargets(staged);
|
||||
if (targets.length === 0) return;
|
||||
if (targets.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
const unstaged = getGitPaths(["diff", "--name-only", "-z"], repoRoot);
|
||||
const partial = findPartiallyStagedFiles(targets, unstaged);
|
||||
@@ -104,7 +114,9 @@ function main() {
|
||||
}
|
||||
|
||||
const filteredTargets = filterOutPartialTargets(targets, partial);
|
||||
if (filteredTargets.length === 0) return;
|
||||
if (filteredTargets.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
const oxfmt = resolveOxfmtCommand(repoRoot);
|
||||
if (!oxfmt) {
|
||||
|
||||
Reference in New Issue
Block a user