-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpackage-extension.js
More file actions
39 lines (31 loc) · 1.25 KB
/
package-extension.js
File metadata and controls
39 lines (31 loc) · 1.25 KB
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
31
32
33
34
35
36
37
38
39
const fs = require('fs-extra');
const util = require('util');
const exec = util.promisify(require('child_process').exec);
const zipper = require('zip-local');
const path = require('path');
async function main() {
// Path to the manifest file
const manifestPath = path.join(__dirname, 'manifest.json');
const version = require(manifestPath).version;
// Run your build script - modify or remove if you don't need a build step
// await exec('npm run build:prod');
const packageDir = path.join(__dirname, `builds/${version}`);
if (fs.existsSync(packageDir)) {
await fs.rm(packageDir, { recursive: true });
}
await fs.mkdirp(packageDir);
// Specify the directories and files to include in the zip
const zipContents = ['_locales', 'icons', 'src', 'manifest.json'];
for await (const filename of zipContents) {
await fs.copy(path.join(__dirname, filename), path.join(packageDir, filename));
}
// Creating the zip file
zipper.sync
.zip(packageDir)
.compress()
.save(`${packageDir}.zip`);
// Optionally, remove the temporary folder
await fs.rm(packageDir, { recursive: true });
console.log('Extension packaged:', `builds/${version}.zip`);
}
main().catch(console.error);