UNPKG

@capawesome/cli

Version:

The Capawesome Cloud Command Line Interface (CLI) to manage Live Updates and more.

20 lines (19 loc) 639 B
import archiver from 'archiver'; class ZipImpl { async zipFolder(sourceFolder) { return new Promise((resolve, reject) => { const archive = archiver('zip', { zlib: { level: 9 } }); const buffers = []; archive.on('data', (data) => buffers.push(data)); archive.on('error', (err) => reject(err)); archive.on('end', () => resolve(Buffer.concat(buffers))); archive.directory(sourceFolder, false); archive.finalize(); }); } isZipped(path) { return path.endsWith('.zip'); } } const zip = new ZipImpl(); export default zip;