(sourceDir: string, outputPath: string, files: string[])
| 1529 | // 创建压缩包 |
| 1530 | private async createArchive(sourceDir: string, outputPath: string, files: string[]): Promise<void> { |
| 1531 | return new Promise((resolve, reject) => { |
| 1532 | const output = fs.createWriteStream(outputPath); |
| 1533 | const archive = archiver('zip', { |
| 1534 | zlib: { level: 9 } // 最高压缩级别 |
| 1535 | }); |
| 1536 | |
| 1537 | output.on('close', () => { |
| 1538 | console.log(`[ssh] 压缩包创建成功: ${archive.pointer()} bytes`); |
| 1539 | resolve(); |
| 1540 | }); |
| 1541 | |
| 1542 | archive.on('error', (err) => { |
| 1543 | reject(err); |
| 1544 | }); |
| 1545 | |
| 1546 | archive.pipe(output); |
| 1547 | |
| 1548 | // 添加文件到压缩包 |
| 1549 | for (const file of files) { |
| 1550 | const filePath = path.join(sourceDir, file); |
| 1551 | if (fs.existsSync(filePath)) { |
| 1552 | archive.file(filePath, { name: file }); |
| 1553 | } |
| 1554 | } |
| 1555 | |
| 1556 | archive.finalize(); |
| 1557 | }); |
| 1558 | } |
| 1559 | |
| 1560 | } |
| 1561 | |
| 1562 | export default new SSHPlugin(); |
no outgoing calls
no test coverage detected