-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathbuild.js
37 lines (33 loc) · 1.08 KB
/
build.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
31
32
33
34
35
36
37
import { readFile, writeFile, copyFile } from "fs/promises";
const isFirefox = process.argv.includes("--firefox");
async function updateManifest() {
try {
const manifestPath = "manifest.json";
const backupPath = "manifest.backup.json";
await copyFile(manifestPath, backupPath).catch(() => {});
const manifestData = await readFile(manifestPath, "utf-8");
const manifest = JSON.parse(manifestData);
if (isFirefox) {
manifest.background = {
page: "background.html",
};
manifest.browser_specific_settings = {
gecko: {
id: "[email protected]",
},
};
} else {
manifest.background = {
service_worker: "scripts/background.js",
type: "module",
persistent: false,
};
delete manifest.browser_specific_settings;
}
await writeFile(manifestPath, JSON.stringify(manifest, null, 2));
console.log(`Manifest updated for ${isFirefox ? "Firefox" : "Chrome"}`);
} catch (error) {
console.error("Error updating manifest.json:", error);
}
}
updateManifest();