forked from JanssenProject/jans
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpack.js
30 lines (25 loc) · 838 Bytes
/
pack.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 { readFileSync, existsSync, mkdirSync } = require('fs');
const { parse, resolve } = require('path');
const AdmZip = require('adm-zip');
try {
const { base } = parse(__dirname);
const { version } = JSON.parse(
readFileSync(resolve(__dirname, 'dist/chrome', 'manifest.json'), 'utf8')
);
const outdir = 'release';
const supportedBrowser = ['chrome', 'firefox']
supportedBrowser.forEach(browser => {
const filename = `${base}-${browser}-v${version}.zip`;
const zip = new AdmZip();
zip.addLocalFolder(`dist/${browser}`);
if (!existsSync(outdir)) {
mkdirSync(outdir);
}
zip.writeZip(`${outdir}/${filename}`);
console.log(
`Success! Created a ${filename} file under ${outdir} directory.`
);
})
} catch (e) {
console.error('Error! Failed to generate a zip file.' + e);
}