fix: devtool startup
This commit is contained in:
		
							parent
							
								
									57028c7ba8
								
							
						
					
					
						commit
						032aa74f6e
					
				@ -68,10 +68,7 @@ async function main() {
 | 
				
			|||||||
  await build();
 | 
					  await build();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // start Zotero
 | 
					  // start Zotero
 | 
				
			||||||
  startZotero();
 | 
					  startZotero(openDevTool);
 | 
				
			||||||
  setTimeout(() => {
 | 
					 | 
				
			||||||
    openDevTool();
 | 
					 | 
				
			||||||
  }, 5000);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // watch
 | 
					  // watch
 | 
				
			||||||
  await watch();
 | 
					  await watch();
 | 
				
			||||||
 | 
				
			|||||||
@ -10,6 +10,9 @@ import { exit } from "process";
 | 
				
			|||||||
const { addonID } = details.config;
 | 
					const { addonID } = details.config;
 | 
				
			||||||
const { zoteroBinPath, profilePath, dataDir } = cmd.exec;
 | 
					const { zoteroBinPath, profilePath, dataDir } = cmd.exec;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// Keep in sync with the addon's onStartup
 | 
				
			||||||
 | 
					const loadDevToolWhen = `Plugin ${addonID} startup`;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const logPath = "logs";
 | 
					const logPath = "logs";
 | 
				
			||||||
const logFilePath = path.join(logPath, "zotero.log");
 | 
					const logFilePath = path.join(logPath, "zotero.log");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -68,7 +71,9 @@ function prepareLog() {
 | 
				
			|||||||
  writeFileSync(logFilePath, "");
 | 
					  writeFileSync(logFilePath, "");
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export function main() {
 | 
					export function main(callback) {
 | 
				
			||||||
 | 
					  let isZoteroReady = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  prepareDevEnv();
 | 
					  prepareDevEnv();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  prepareLog();
 | 
					  prepareLog();
 | 
				
			||||||
@ -81,6 +86,10 @@ export function main() {
 | 
				
			|||||||
  ]);
 | 
					  ]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  zoteroProcess.stdout.on("data", (data) => {
 | 
					  zoteroProcess.stdout.on("data", (data) => {
 | 
				
			||||||
 | 
					    if (!isZoteroReady && data.toString().includes(loadDevToolWhen)) {
 | 
				
			||||||
 | 
					      isZoteroReady = true;
 | 
				
			||||||
 | 
					      callback();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
    writeFileSync(logFilePath, data, {
 | 
					    writeFileSync(logFilePath, data, {
 | 
				
			||||||
      flag: "a",
 | 
					      flag: "a",
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
 | 
				
			|||||||
@ -16,6 +16,14 @@ async function onStartup() {
 | 
				
			|||||||
    Zotero.unlockPromise,
 | 
					    Zotero.unlockPromise,
 | 
				
			||||||
    Zotero.uiReadyPromise,
 | 
					    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();
 | 
					  initLocale();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  BasicExampleFactory.registerPrefs();
 | 
					  BasicExampleFactory.registerPrefs();
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user