-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpack.js
30 lines (27 loc) · 896 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
import AdmZip from 'adm-zip';
import { readFileSync, existsSync, mkdirSync } from 'fs';
import { parse, resolve } from 'path';
import path from 'path';
import { fileURLToPath } from 'url';
try {
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const { base } = parse(__dirname);
const { version } = JSON.parse(
readFileSync(resolve(__dirname, 'build', 'manifest.json'), 'utf8')
);
const outdir = 'release';
const filename = `${base}-v${version}.zip`;
const zip = new AdmZip();
zip.addLocalFolder('build');
if (!existsSync(outdir)) {
mkdirSync(outdir);
}
zip.writeZip(`${outdir}/${filename}`);
console.log(
`Success! Created a ${filename} file under ${outdir} directory. You can upload this file to web store.`
);
} catch (e) {
console.error('Error! Failed to generate a zip file.');
console.error(e);
}