Skip to content

Commit

Permalink
update: template
Browse files Browse the repository at this point in the history
  • Loading branch information
windingwind committed Dec 14, 2023
1 parent 452f6f0 commit 1e9236d
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 5 deletions.
5 changes: 1 addition & 4 deletions scripts/server.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,7 @@ async function main() {
await build();

// start Zotero
startZotero();
setTimeout(() => {
openDevTool();
}, 2000);
startZotero(openDevTool);

// watch
await watch();
Expand Down
11 changes: 10 additions & 1 deletion scripts/start.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ import { exit } from "process";
const { addonID } = details.config;
const { zoteroBinPath, profilePath, dataDir } = cmd.exec;

// Keep in sync with the addon's onStartup
const loadDevToolWhen = `Plugin ${addonID} startup`;

const logPath = "logs";
const logFilePath = path.join(logPath, "zotero.log");

Expand Down Expand Up @@ -68,7 +71,9 @@ function prepareLog() {
writeFileSync(logFilePath, "");
}

export function main() {
export function main(callback) {
let isZoteroReady = false;

prepareDevEnv();

prepareLog();
Expand All @@ -81,6 +86,10 @@ export function main() {
]);

zoteroProcess.stdout.on("data", (data) => {
if (!isZoteroReady && data.toString().includes(loadDevToolWhen)) {
isZoteroReady = true;
callback();
}
writeFileSync(logFilePath, data, {
flag: "a",
});
Expand Down
File renamed without changes.
8 changes: 8 additions & 0 deletions src/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ async function onStartup() {
Zotero.unlockPromise,
Zotero.uiReadyPromise,
]);

// TODO: Remove this after zotero#3387 is merged
if (__env__ === "development") {
// Keep in sync with the scripts/startup.mjs
const loadDevToolWhen = `Plugin ${config.addonID} startup`;
ztoolkit.log(loadDevToolWhen);
}

initLocale();

initActions();
Expand Down

0 comments on commit 1e9236d

Please sign in to comment.