-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.js
29 lines (25 loc) · 1.13 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
//Hi, you should run me in Node.js
const fs=require("fs");
const path=require("path");
function copyFolderSync(from, to) {
if(fs.existsSync(to)) fs.rmdirSync(to, {recursive: true});
fs.mkdirSync(to);
fs.readdirSync(from).forEach(element => {
if (fs.lstatSync(path.join(from, element)).isFile()) {
fs.copyFileSync(path.join(from, element), path.join(to, element));
} else {
copyFolderSync(path.join(from, element), path.join(to, element));
}
});
}
//build for Chrome:
copyFolderSync("browser-extension", "built_for_chrome");
fs.unlinkSync("built_for_chrome/manifest_firefox.json");
fs.renameSync("built_for_chrome/manifest_chrome.json", "built_for_chrome/manifest.json")
//build for Firefox:
copyFolderSync("browser-extension", "built_for_firefox");
fs.unlinkSync("built_for_firefox/manifest_chrome.json");
fs.renameSync("built_for_firefox/manifest_firefox.json", "built_for_firefox/manifest.json")
let txt=fs.readFileSync("built_for_firefox/biasshield.css", "utf8");
txt=txt.replace(/chrome-extension:\/\/__MSG_@@extension_id__\//g, "");
fs.writeFileSync("built_for_firefox/biasshield.css", txt, "utf8");