Merge pull request #65 from northword/check-manifest-before-start

fix: check manifest before start
This commit is contained in:
windingwind 2023-07-17 23:20:11 +08:00 committed by GitHub
commit 9da839374c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 6 deletions

View File

@ -9,19 +9,25 @@ const { addonID } = details.config;
const { zoteroBinPath, profilePath, dataDir } = cmd.exec; const { zoteroBinPath, profilePath, dataDir } = cmd.exec;
if (!existsSync(zoteroBinPath)) { if (!existsSync(zoteroBinPath)) {
throw new Error("Zotero bin do no exist."); throw new Error("Zotero binary does not exist.");
} }
if (existsSync(profilePath)) { if (existsSync(profilePath)) {
const addonProxyFilePath = path.join(profilePath, `extensions/${addonID}`); const addonProxyFilePath = path.join(profilePath, `extensions/${addonID}`);
const buildPath = path.resolve("build/addon"); const buildPath = path.resolve("build/addon");
if (!existsSync(path.join(buildPath, "./manifest.json"))) {
throw new Error(
`The built file does not exist, maybe you need to build the addon first.`,
);
}
function writeAddonProxyFile() { function writeAddonProxyFile() {
writeFileSync(addonProxyFilePath, buildPath); writeFileSync(addonProxyFilePath, buildPath);
console.log( console.log(
`[info] Addon proxy file has been updated. \n `[info] Addon proxy file has been updated.
File path: ${addonProxyFilePath} \n File path: ${addonProxyFilePath}
Addon path: ${buildPath} \n`, Addon path: ${buildPath} `,
); );
} }

View File

@ -8,12 +8,12 @@
"zoteroBinPath": "/path/to/zotero.exe", "zoteroBinPath": "/path/to/zotero.exe",
"@comment-profilePath": "Please input the path of the profile used for development in `profilePath`.", "@comment-profilePath": "Please input the path of the profile used for development in `profilePath`.",
"@comment-profilePath-tip": "If this field is kept empty, Zotero will start with the default profile.", "@comment-profilePath-tip": "Start the profile manager by `/path/to/zotero.exe -p` to create a profile for development",
"@comment-profilePath-see": "https://www.zotero.org/support/kb/profile_directory", "@comment-profilePath-see": "https://www.zotero.org/support/kb/profile_directory",
"profilePath": "/path/to/profile", "profilePath": "/path/to/profile",
"@comment-dataDir": "Please input the directory where the database is located in dataDir", "@comment-dataDir": "Please input the directory where the database is located in dataDir",
"@comment-dataDir-tip": "If this field is kept empty, Zotero will start with the default date.", "@comment-dataDir-tip": "If this field is kept empty, Zotero will start with the default data.",
"@comment-dataDir-see": "https://www.zotero.org/support/zotero_data", "@comment-dataDir-see": "https://www.zotero.org/support/zotero_data",
"dataDir": "" "dataDir": ""
} }