mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-03 13:22:14 +00:00
fix(ci): default local low-memory checks
This commit is contained in:
42
scripts/run-oxlint.mjs
Normal file
42
scripts/run-oxlint.mjs
Normal file
@@ -0,0 +1,42 @@
|
||||
import { spawnSync } from "node:child_process";
|
||||
import path from "node:path";
|
||||
|
||||
const isLocalCheckEnabled = (env) => {
|
||||
const raw = env.OPENCLAW_LOCAL_CHECK?.trim().toLowerCase();
|
||||
return raw !== "0" && raw !== "false";
|
||||
};
|
||||
|
||||
const hasFlag = (args, name) => args.some((arg) => arg === name || arg.startsWith(`${name}=`));
|
||||
|
||||
const args = process.argv.slice(2);
|
||||
const env = { ...process.env };
|
||||
const finalArgs = [...args];
|
||||
const separatorIndex = finalArgs.indexOf("--");
|
||||
|
||||
const insertBeforeSeparator = (...items) => {
|
||||
const index = separatorIndex === -1 ? finalArgs.length : separatorIndex;
|
||||
finalArgs.splice(index, 0, ...items);
|
||||
};
|
||||
|
||||
if (!hasFlag(finalArgs, "--type-aware")) {
|
||||
insertBeforeSeparator("--type-aware");
|
||||
}
|
||||
if (!hasFlag(finalArgs, "--tsconfig")) {
|
||||
insertBeforeSeparator("--tsconfig", "tsconfig.oxlint.json");
|
||||
}
|
||||
if (isLocalCheckEnabled(env) && !hasFlag(finalArgs, "--threads")) {
|
||||
insertBeforeSeparator("--threads=1");
|
||||
}
|
||||
|
||||
const oxlintPath = path.resolve("node_modules", ".bin", "oxlint");
|
||||
const result = spawnSync(oxlintPath, finalArgs, {
|
||||
stdio: "inherit",
|
||||
env,
|
||||
shell: process.platform === "win32",
|
||||
});
|
||||
|
||||
if (result.error) {
|
||||
throw result.error;
|
||||
}
|
||||
|
||||
process.exit(result.status ?? 1);
|
||||
37
scripts/run-tsgo.mjs
Normal file
37
scripts/run-tsgo.mjs
Normal file
@@ -0,0 +1,37 @@
|
||||
import { spawnSync } from "node:child_process";
|
||||
import path from "node:path";
|
||||
|
||||
const isLocalCheckEnabled = (env) => {
|
||||
const raw = env.OPENCLAW_LOCAL_CHECK?.trim().toLowerCase();
|
||||
return raw !== "0" && raw !== "false";
|
||||
};
|
||||
|
||||
const args = process.argv.slice(2);
|
||||
const env = { ...process.env };
|
||||
const finalArgs = [...args];
|
||||
const separatorIndex = finalArgs.indexOf("--");
|
||||
|
||||
const insertBeforeSeparator = (...items) => {
|
||||
const index = separatorIndex === -1 ? finalArgs.length : separatorIndex;
|
||||
finalArgs.splice(index, 0, ...items);
|
||||
};
|
||||
|
||||
if (isLocalCheckEnabled(env) && !finalArgs.includes("--singleThreaded")) {
|
||||
insertBeforeSeparator("--singleThreaded");
|
||||
if (!env.GOGC) {
|
||||
env.GOGC = "30";
|
||||
}
|
||||
}
|
||||
|
||||
const tsgoPath = path.resolve("node_modules", ".bin", "tsgo");
|
||||
const result = spawnSync(tsgoPath, finalArgs, {
|
||||
stdio: "inherit",
|
||||
env,
|
||||
shell: process.platform === "win32",
|
||||
});
|
||||
|
||||
if (result.error) {
|
||||
throw result.error;
|
||||
}
|
||||
|
||||
process.exit(result.status ?? 1);
|
||||
Reference in New Issue
Block a user