MCPcopy
hub / github.com/qawolf/cli / buildArchive

Function buildArchive

src/domains/flows/pull/extract.test.ts:38–60  ·  view source on GitHub ↗
(
  archivePathArg: string,
  entries: StagedEntry[],
)

Source from the content-addressed store, hash-verified

36 | { kind: "symlink"; name: string; target: string };
37
38async function buildArchive(
39 archivePathArg: string,
40 entries: StagedEntry[],
41): Promise<void> {
42 const stage = await mkdtemp(join(tmpdir(), "qawolf-stage-"));
43 try {
44 for (const e of entries) {
45 const target = join(stage, e.name);
46 await mkdir(join(target, ".."), { recursive: true });
47 if (e.kind === "file") {
48 await writeFile(target, e.data);
49 } else {
50 await symlink(e.target, target);
51 }
52 }
53 await tar.c(
54 { gzip: true, file: archivePathArg, cwd: stage },
55 entries.map((e) => e.name),
56 );
57 } finally {
58 await rm(stage, { recursive: true, force: true });
59 }
60}
61
62// Minimal raw-tar+gzip writer for fixtures we can't build with tar.c
63// (paths with `..`, absolute names — tar.c rejects/strips them).

Callers 1

extract.test.tsFile · 0.85

Calls 3

mkdirFunction · 0.50
writeFileFunction · 0.50
rmFunction · 0.50

Tested by

no test coverage detected