mirror of
https://github.com/moltbot/moltbot.git
synced 2026-04-18 04:04:27 +00:00
fix(lint): skip heavy-check lock for explicit oxlint files
This commit is contained in:
@@ -84,6 +84,36 @@ export function applyLocalOxlintPolicy(args, env, hostResources) {
|
||||
return { env: nextEnv, args: nextArgs };
|
||||
}
|
||||
|
||||
export function shouldAcquireLocalHeavyCheckLockForOxlint(
|
||||
args,
|
||||
{ cwd = process.cwd(), env = process.env } = {},
|
||||
) {
|
||||
if (env.OPENCLAW_OXLINT_FORCE_LOCK === "1") {
|
||||
return true;
|
||||
}
|
||||
|
||||
const separatorIndex = args.indexOf("--");
|
||||
const candidateArgs = (() => {
|
||||
if (separatorIndex !== -1) {
|
||||
return args.slice(separatorIndex + 1);
|
||||
}
|
||||
const firstFlagIndex = args.findIndex((arg) => arg.startsWith("-"));
|
||||
return firstFlagIndex === -1 ? args : args.slice(0, firstFlagIndex);
|
||||
})();
|
||||
const explicitTargets = candidateArgs.filter((arg) => arg.length > 0 && !arg.startsWith("-"));
|
||||
if (explicitTargets.length === 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return !explicitTargets.every((target) => {
|
||||
try {
|
||||
return fs.statSync(path.resolve(cwd, target)).isFile();
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
export function shouldThrottleLocalHeavyChecks(env, hostResources) {
|
||||
if (!isLocalCheckEnabled(env)) {
|
||||
return false;
|
||||
|
||||
@@ -3,16 +3,22 @@ import path from "node:path";
|
||||
import {
|
||||
acquireLocalHeavyCheckLockSync,
|
||||
applyLocalOxlintPolicy,
|
||||
shouldAcquireLocalHeavyCheckLockForOxlint,
|
||||
} from "./lib/local-heavy-check-runtime.mjs";
|
||||
|
||||
const { args: finalArgs, env } = applyLocalOxlintPolicy(process.argv.slice(2), process.env);
|
||||
|
||||
const oxlintPath = path.resolve("node_modules", ".bin", "oxlint");
|
||||
const releaseLock = acquireLocalHeavyCheckLockSync({
|
||||
const releaseLock = shouldAcquireLocalHeavyCheckLockForOxlint(finalArgs, {
|
||||
cwd: process.cwd(),
|
||||
env,
|
||||
toolName: "oxlint",
|
||||
});
|
||||
})
|
||||
? acquireLocalHeavyCheckLockSync({
|
||||
cwd: process.cwd(),
|
||||
env,
|
||||
toolName: "oxlint",
|
||||
})
|
||||
: () => {};
|
||||
|
||||
try {
|
||||
const result = spawnSync(oxlintPath, finalArgs, {
|
||||
|
||||
Reference in New Issue
Block a user