@@ -19,11 +19,11 @@ export default class Serve extends Base {
1919
2020 async run ( ) {
2121 // build
22- this . builder . run ( ) ;
22+ await this . builder . run ( ) ;
2323
2424 // start Zotero
25- // this.startZotero();
26- this . startZoteroWebExt ( ) ;
25+ this . startZotero ( ) ;
26+ // this.startZoteroWebExt();
2727
2828 // watch
2929 await this . config . extraServer ( this . config ) ;
@@ -78,7 +78,8 @@ export default class Serve extends Base {
7878 } ) ;
7979 }
8080
81- startZotero ( ) {
81+ async startZotero ( ) {
82+ let isZoteroReady = false ;
8283 if ( ! fs . existsSync ( this . zoteroBinPath ) ) {
8384 throw new Error ( "Zotero binary does not exist." ) ;
8485 }
@@ -87,13 +88,32 @@ export default class Serve extends Base {
8788 throw new Error ( "The given Zotero profile does not exist." ) ;
8889 }
8990
91+ this . prepareDevEnv ( ) ;
92+
9093 const zoteroProcess = spawn ( this . zoteroBinPath , [
9194 "--debugger" ,
9295 "--purgecaches" ,
9396 "-profile" ,
9497 this . profilePath ,
9598 ] ) ;
9699
100+ zoteroProcess . stdout ?. on ( "data" , ( data ) => {
101+ if (
102+ ! isZoteroReady &&
103+ data
104+ . toString ( )
105+ . includes (
106+ `Calling bootstrap method 'startup' for plugin ${ this . addonID } ` ,
107+ )
108+ ) {
109+ console . log ( data . toString ( ) ) ;
110+ isZoteroReady = true ;
111+ setTimeout ( ( ) => {
112+ this . openDevTool ( ) ;
113+ } , 1000 ) ;
114+ }
115+ } ) ;
116+
97117 zoteroProcess . on ( "close" , ( code ) => {
98118 this . logger . info ( `Zotero terminated with code ${ code } .` ) ;
99119 exit ( 0 ) ;
@@ -104,6 +124,8 @@ export default class Serve extends Base {
104124 zoteroProcess . kill ( ) ;
105125 exit ( ) ;
106126 } ) ;
127+
128+ return zoteroProcess ;
107129 }
108130
109131 /**
@@ -266,11 +288,11 @@ export default class Serve extends Base {
266288 }
267289
268290 private get zoteroBinPath ( ) {
269- this . logger . debug ( "zoteroBinPath" , process . env . zoteroBinPath ) ;
291+ // this.logger.debug("zoteroBinPath", process.env.zoteroBinPath);
270292 return process . env . zoteroBinPath ?? "" ;
271293 }
272294 private get profilePath ( ) {
273- this . logger . debug ( "profilePath" , process . env . profilePath ) ;
295+ // this.logger.debug("profilePath", process.env.profilePath);
274296 return process . env . profilePath ?? "" ;
275297 }
276298 private get dataDir ( ) {
0 commit comments