mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-18 23:11:33 +00:00
fix(scripts): reject short flag values in release docs parsers
This commit is contained in:
@@ -30,12 +30,19 @@ function runNode(args: string[], env: NodeJS.ProcessEnv = {}) {
|
||||
const e = error as { stdout?: unknown; stderr?: unknown };
|
||||
return {
|
||||
ok: false,
|
||||
stdout: Buffer.isBuffer(e.stdout) ? e.stdout.toString("utf8") : String(e.stdout ?? ""),
|
||||
stderr: Buffer.isBuffer(e.stderr) ? e.stderr.toString("utf8") : String(e.stderr ?? ""),
|
||||
stdout: formatProcessOutput(e.stdout),
|
||||
stderr: formatProcessOutput(e.stderr),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
function formatProcessOutput(value: unknown): string {
|
||||
if (Buffer.isBuffer(value)) {
|
||||
return value.toString("utf8");
|
||||
}
|
||||
return typeof value === "string" ? value : "";
|
||||
}
|
||||
|
||||
function runGit(args: string[], cwd?: string, env: NodeJS.ProcessEnv = {}) {
|
||||
execFileSync("git", args, {
|
||||
cwd,
|
||||
@@ -127,11 +134,17 @@ describe("scripts/android-release-signing.mjs", () => {
|
||||
it.each([
|
||||
["--mode"],
|
||||
["--mode", "--manifest"],
|
||||
["--mode", "-h"],
|
||||
["--manifest"],
|
||||
["--manifest", "-h"],
|
||||
["--workspace", "--mode"],
|
||||
["--workspace", "-h"],
|
||||
["--materialized-dir", "--mode"],
|
||||
["--materialized-dir", "-h"],
|
||||
["--keystore", "--mode"],
|
||||
["--keystore", "-h"],
|
||||
["--properties", "--mode"],
|
||||
["--properties", "-h"],
|
||||
])("rejects missing values for %s before release signing work", (...args) => {
|
||||
const result = runNode(args);
|
||||
|
||||
|
||||
@@ -20,11 +20,13 @@ describe("scripts/check-docs-mdx", () => {
|
||||
expect(() => parseArgs(["--max-errors", "0"])).toThrow(
|
||||
"--max-errors must be a positive integer",
|
||||
);
|
||||
expect(() => parseArgs(["--max-errors"])).toThrow("--max-errors must be a positive integer");
|
||||
expect(() => parseArgs(["--max-errors"])).toThrow("--max-errors requires a value");
|
||||
expect(() => parseArgs(["--max-errors", "-h"])).toThrow("--max-errors requires a value");
|
||||
});
|
||||
|
||||
it("rejects missing JSON report output paths", () => {
|
||||
expect(() => parseArgs(["--json-out"])).toThrow("--json-out requires a value");
|
||||
expect(() => parseArgs(["--json-out", "-h"])).toThrow("--json-out requires a value");
|
||||
expect(() => parseArgs(["--json-out", "--max-errors", "3"])).toThrow(
|
||||
"--json-out requires a value",
|
||||
);
|
||||
|
||||
@@ -16,12 +16,19 @@ function runSigningResult(args: string[]): { ok: boolean; stdout: string; stderr
|
||||
const e = error as { stdout?: unknown; stderr?: unknown };
|
||||
return {
|
||||
ok: false,
|
||||
stdout: Buffer.isBuffer(e.stdout) ? e.stdout.toString("utf8") : String(e.stdout ?? ""),
|
||||
stderr: Buffer.isBuffer(e.stderr) ? e.stderr.toString("utf8") : String(e.stderr ?? ""),
|
||||
stdout: formatProcessOutput(e.stdout),
|
||||
stderr: formatProcessOutput(e.stderr),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
function formatProcessOutput(value: unknown): string {
|
||||
if (Buffer.isBuffer(value)) {
|
||||
return value.toString("utf8");
|
||||
}
|
||||
return typeof value === "string" ? value : "";
|
||||
}
|
||||
|
||||
function runSigning(mode: string): string {
|
||||
return execFileSync(process.execPath, [SCRIPT, "--mode", mode], {
|
||||
encoding: "utf8",
|
||||
@@ -33,7 +40,9 @@ describe("scripts/ios-release-signing.mjs", () => {
|
||||
it.each([
|
||||
["--mode"],
|
||||
["--mode", "--manifest"],
|
||||
["--mode", "-h"],
|
||||
["--manifest"],
|
||||
["--manifest", "-h"],
|
||||
])("rejects missing values for %s before reading signing manifests", (...args) => {
|
||||
const result = runSigningResult(args);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user