forked from cloudspout/cloudspout-button-panel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathzip.js
30 lines (23 loc) · 732 Bytes
/
zip.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
const fs = require('fs');
const archiver = require('archiver');
const glob = require("glob")
const cwd = 'dist/'
const folderPath = '**';
const out = 'cloudspout-button-panel.zip';
glob(folderPath, {cwd}, (err, files) => {
if (err) {
console.error(err);
return err;
}
const output = fs.createWriteStream('./' + out);
const archive = archiver('zip', {zlib:{level: 9}});
archive.pipe(output);
// Linux needs the root folder itself
archive.file(cwd, {name:'cloudspout-button-panel/'})
files.forEach(file => {
if (file === out) return;
console.log(file);
archive.file(cwd + file, {name:'cloudspout-button-panel/'+file});
});
archive.finalize();
});