Remove original xpi file if exists in extensions folder (#90)

* remove original xpi file in extensions folder to avoid load add-on from xpi

* Update README.md
This commit is contained in:
syt 2023-12-18 15:49:00 +08:00 committed by GitHub
parent f5f2fd3297
commit fc8a4ac9d9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 2 deletions

View File

@ -251,7 +251,7 @@ Steps in `scripts/build.mjs`:
- Create/empty `build/`.
- Copy `addon/**` to `build/addon/**`
- Replace placeholders: use `replace-in-file` to replace keywords and configurations defined in `package.json` in non-build files (`xhtml`, `json`, et al.).
- Prepare locale files to [avaid conflict](https://www.zotero.org/support/dev/zotero_7_for_developers#avoiding_localization_conflicts)
- Prepare locale files to [avoid conflict](https://www.zotero.org/support/dev/zotero_7_for_developers#avoiding_localization_conflicts)
- Rename `**/*.flt` to `**/${addonRef}-*.flt`
- Prefix each fluent message with `addonRef-`
- Use Esbuild to build `.ts` source code to `.js`, build `src/index.ts` to `./build/addon/chrome/content/scripts`.

View File

@ -2,7 +2,7 @@ import details from "../package.json" assert { type: "json" };
import { Logger } from "./utils.mjs";
import cmd from "./zotero-cmd.json" assert { type: "json" };
import { spawn } from "child_process";
import { existsSync, readFileSync, writeFileSync } from "fs";
import { existsSync, readFileSync, writeFileSync, rmSync } from "fs";
import { clearFolder } from "./utils.mjs";
import path from "path";
import { exit } from "process";
@ -45,6 +45,11 @@ function prepareDevEnv() {
writeAddonProxyFile();
}
const addonXpiFilePath = path.join(profilePath, `extensions/${addonID}.xpi`);
if (existsSync(addonXpiFilePath)) {
rmSync(addonXpiFilePath);
}
const prefsPath = path.join(profilePath, "prefs.js");
if (existsSync(prefsPath)) {
const PrefsLines = readFileSync(prefsPath, "utf-8").split("\n");