
























11import { spawnSync } from "node:child_process";
2-import { mkdtempSync, rmSync, mkdirSync, writeFileSync } from "node:fs";
2+import {
3+chmodSync,
4+existsSync,
5+mkdtempSync,
6+mkdirSync,
7+readFileSync,
8+rmSync,
9+writeFileSync,
10+} from "node:fs";
311import { tmpdir } from "node:os";
4-import { dirname, join } from "node:path";
12+import { delimiter, dirname, join } from "node:path";
513import { describe, expect, it } from "vitest";
614import { LOCAL_BUILD_METADATA_DIST_PATHS } from "../../scripts/lib/local-build-metadata-paths.mjs";
715@@ -67,6 +75,47 @@ function withTarball(
6775}
68766977describe("check-openclaw-package-tarball", () => {
78+it.runIf(process.platform !== "win32")("removes the extract dir when tar extraction fails", () => {
79+const root = mkdtempSync(join(tmpdir(), "openclaw-package-tarball-extract-fail-"));
80+try {
81+const fakeBin = join(root, "bin");
82+mkdirSync(fakeBin);
83+const extractDirFile = join(root, "extract-dir.txt");
84+const fakeTar = join(fakeBin, "tar");
85+writeFileSync(
86+fakeTar,
87+[
88+"#!/usr/bin/env node",
89+"const fs = require('node:fs');",
90+"const args = process.argv.slice(2);",
91+"if (args[0] === '-tf') { console.log('package/package.json'); process.exit(0); }",
92+"const outputDir = args[args.indexOf('-C') + 1];",
93+"fs.writeFileSync(process.env.OPENCLAW_TEST_EXTRACT_DIR_FILE, outputDir);",
94+"console.error('extract denied');",
95+"process.exit(7);",
96+].join("\n"),
97+);
98+chmodSync(fakeTar, 0o755);
99+const tarball = join(root, "openclaw.tgz");
100+writeFileSync(tarball, "not used by fake tar");
101+102+const result = spawnSync("node", [CHECK_SCRIPT, tarball], {
103+encoding: "utf8",
104+env: {
105+ ...process.env,
106+OPENCLAW_TEST_EXTRACT_DIR_FILE: extractDirFile,
107+PATH: `${fakeBin}${delimiter}${process.env.PATH ?? ""}`,
108+},
109+});
110+111+expect(result.status).not.toBe(0);
112+expect(result.stderr).toContain("extract denied");
113+expect(existsSync(readFileSync(extractDirFile, "utf8"))).toBe(false);
114+} finally {
115+rmSync(root, { recursive: true, force: true });
116+}
117+});
118+70119it("allows legacy private QA inventory entries omitted from shipped tarballs through 2026.4.25", () => {
71120withTarball(
72121["dist/index.js", "dist/extensions/qa-channel/runtime-api.js"],
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。