mirror of
https://github.com/eigent-ai/eigent.git
synced 2026-05-16 19:50:50 +00:00
25 lines
589 B
TypeScript
25 lines
589 B
TypeScript
import fs from 'node:fs'
|
|
// @ts-ignore
|
|
import archiver from 'archiver'
|
|
import log from 'electron-log'
|
|
|
|
export function zipFolder(folderPath: string, outputZipPath: string): Promise<string> {
|
|
return new Promise((resolve, reject) => {
|
|
const output = fs.createWriteStream(outputZipPath)
|
|
const archive = archiver('zip', { zlib: { level: 9 } })
|
|
|
|
output.on('close', () => resolve(outputZipPath))
|
|
|
|
archive.on('error', (err: any) => {
|
|
log.error('Archive error:', err);
|
|
reject(err);
|
|
})
|
|
|
|
archive.pipe(output)
|
|
archive.directory(folderPath, false)
|
|
archive.finalize()
|
|
})
|
|
}
|
|
|
|
|
|
|