-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild
executable file
·42 lines (31 loc) · 1.16 KB
/
build
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
40
41
42
#!/usr/bin/env node
const child_process = require('child_process');
const fs = require('fs');
const manifestBase = require('./manifest.json');
const manifestChromeExtra = require('./manifest-chrome-extra.json');
const manifestFirefoxExtra = require('./manifest-firefox-extra.json');
function copy(obj) {
return JSON.parse(JSON.stringify(obj));
}
const chromeManifest = Object.assign(copy(manifestBase), manifestChromeExtra);
const firefoxManifest = Object.assign(copy(manifestBase), manifestFirefoxExtra);
try {
fs.unlinkSync("firefox.zip");
fs.unlinkSync("chrome.zip");
} catch(err) {}
child_process.execSync("mv manifest.json manifest-base.json");
try {
fs.writeFileSync("manifest.json", JSON.stringify(chromeManifest, null, 2), 'utf8');
child_process.execSync("./zip chrome.zip");
fs.unlinkSync("manifest.json");
fs.writeFileSync("manifest.json", JSON.stringify(firefoxManifest, null, 2), 'utf8');
child_process.execSync("./zip firefox.xpi");
fs.unlinkSync("manifest.json");
process.exit(0);
} finally {
try {
fs.unlinkSync("manifest.json");
} catch(err) {}
child_process.execSync("mv manifest-base.json manifest.json");
process.exit(1);
}