(
entries: Array<{ name: string; data: string | Buffer; mode?: number }>,
)
| 8 | import { downloadZip, extractZip } from '../../src/plugin/archive'; |
| 9 | |
| 10 | async function createZipBuffer( |
| 11 | entries: Array<{ name: string; data: string | Buffer; mode?: number }>, |
| 12 | ): Promise<Buffer> { |
| 13 | return new Promise((resolve, reject) => { |
| 14 | const zipfile = new yazl.ZipFile(); |
| 15 | const chunks: Buffer[] = []; |
| 16 | zipfile.outputStream.on('data', (chunk) => chunks.push(chunk)); |
| 17 | zipfile.outputStream.on('end', () => { |
| 18 | resolve(Buffer.concat(chunks)); |
| 19 | }); |
| 20 | zipfile.outputStream.on('error', reject); |
| 21 | for (const entry of entries) { |
| 22 | zipfile.addBuffer( |
| 23 | Buffer.isBuffer(entry.data) ? entry.data : Buffer.from(entry.data), |
| 24 | entry.name, |
| 25 | entry.mode === undefined ? undefined : { mode: entry.mode }, |
| 26 | ); |
| 27 | } |
| 28 | zipfile.end(); |
| 29 | }); |
| 30 | } |
| 31 | |
| 32 | function createMinimalZip(entryName: string, content: string): Buffer { |
| 33 | const nameBuf = Buffer.from(entryName, 'utf8'); |
no test coverage detected