





















@@ -21,14 +21,17 @@ function usage() {
2121function parseArgs(argv) {
2222const options = {
2323dir: "",
24+help: false,
2425input: "",
2526ref: "",
2627repo: "",
2728workflow: DEFAULT_WORKFLOW,
2829};
2930for (let index = 0; index < argv.length; index += 1) {
3031const arg = argv[index];
31-if (arg === "--repo") {
32+if (arg === "--help" || arg === "-h") {
33+options.help = true;
34+} else if (arg === "--repo") {
3235options.repo = argv[(index += 1)] ?? "";
3336} else if (arg?.startsWith("--repo=")) {
3437options.repo = arg.slice("--repo=".length);
@@ -50,6 +53,9 @@ function parseArgs(argv) {
5053throw new Error(`unknown argument: ${arg}\n${usage()}`);
5154}
5255}
56+if (options.help) {
57+return options;
58+}
5359if (!options.input || !options.workflow) {
5460throw new Error(usage());
5561}
@@ -156,7 +162,7 @@ function ghWorkflowCommand(lanes, ref, workflow, reuseInputs = {}) {
156162}
157163158164function detectRepo() {
159-return JSON.parse(run("gh", ["repo", "view", "--json", "nameWithOwner"])).nameWithOwner;
165+return run("gh", ["repo", "view", "--json", "nameWithOwner", "--jq", ".nameWithOwner"]).trim();
160166}
161167162168function findFiles(rootDir, basenames, out = []) {
@@ -296,27 +302,40 @@ function printEntries(entries, ref, workflow, run) {
296302}
297303}
298304299-const options = parseArgs(process.argv.slice(2));
300-const isLocalJson = fs.existsSync(options.input) && fs.statSync(options.input).isFile();
301-if (isLocalJson) {
302-const ref = options.ref || process.env.GITHUB_SHA || "HEAD";
303-printEntries(
304-mergeByLane(failedLaneEntriesFromJson(options.input, ref, options.workflow)),
305-ref,
306-options.workflow,
307-);
308-} else {
309-const repo = options.repo || detectRepo();
310-const run = runInfo(options.input, repo);
311-const ref = options.ref || run.headSha || run.headBranch;
312-const outputDir =
313-options.dir || path.join(os.tmpdir(), `openclaw-docker-e2e-rerun-${options.input}`);
314-const artifactNames = downloadDockerArtifacts(options.input, repo, outputDir);
315-const files = findFiles(outputDir, new Set(["failures.json", "summary.json"]));
316-const entries = mergeByLane(
317-files.flatMap((file) => failedLaneEntriesFromJson(file, ref, options.workflow)),
318-);
319-console.log(`Artifacts: ${artifactNames.join(", ")}`);
320-console.log(`Downloaded: ${outputDir}`);
321-printEntries(entries, ref, options.workflow, run);
305+function main() {
306+const options = parseArgs(process.argv.slice(2));
307+if (options.help) {
308+console.log(usage());
309+return;
310+}
311+const isLocalJson = fs.existsSync(options.input) && fs.statSync(options.input).isFile();
312+if (isLocalJson) {
313+const ref = options.ref || process.env.GITHUB_SHA || "HEAD";
314+printEntries(
315+mergeByLane(failedLaneEntriesFromJson(options.input, ref, options.workflow)),
316+ref,
317+options.workflow,
318+);
319+} else {
320+const repo = options.repo || detectRepo();
321+const run = runInfo(options.input, repo);
322+const ref = options.ref || run.headSha || run.headBranch;
323+const outputDir =
324+options.dir || path.join(os.tmpdir(), `openclaw-docker-e2e-rerun-${options.input}`);
325+const artifactNames = downloadDockerArtifacts(options.input, repo, outputDir);
326+const files = findFiles(outputDir, new Set(["failures.json", "summary.json"]));
327+const entries = mergeByLane(
328+files.flatMap((file) => failedLaneEntriesFromJson(file, ref, options.workflow)),
329+);
330+console.log(`Artifacts: ${artifactNames.join(", ")}`);
331+console.log(`Downloaded: ${outputDir}`);
332+printEntries(entries, ref, options.workflow, run);
333+}
334+}
335+336+try {
337+main();
338+} catch (error) {
339+console.error(error instanceof Error ? error.message : String(error));
340+process.exit(1);
322341}
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。