( archivePathArg: string, entries: StagedEntry[], )
| 36 | | { kind: "symlink"; name: string; target: string }; |
| 37 | |
| 38 | async 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). |
no test coverage detected