@@ -16,7 +16,6 @@ function getDirname(): string {
1616 return path . dirname ( fileURLToPath ( import . meta. url ) ) ;
1717 }
1818 // CJS environment
19- // eslint-disable-next-line no-restricted-globals
2019 return __dirname ;
2120}
2221
@@ -30,7 +29,7 @@ function findRepoRoot(startDir: string): string {
3029 const pkgPath = path . join ( dir , 'package.json' ) ;
3130 if ( fs . existsSync ( pkgPath ) ) {
3231 try {
33- const pkg = JSON . parse ( fs . readFileSync ( pkgPath , 'utf8' ) ) ;
32+ const pkg = JSON . parse ( fs . readFileSync ( pkgPath , 'utf8' ) ) as { workspaces ?: string [ ] } ;
3433 if ( pkg . workspaces ) {
3534 return dir ;
3635 }
@@ -112,8 +111,13 @@ export async function startSpotlight(options: SpotlightOptions = {}): Promise<Sp
112111
113112 // Parse stderr for port information
114113 // Spotlight outputs something like "Spotlight listening on http://localhost:8969"
114+ if ( ! spotlightProcess . stderr || ! spotlightProcess . stdout ) {
115+ reject ( new Error ( 'Spotlight process has no stdout/stderr' ) ) ;
116+ return ;
117+ }
118+
115119 const stderrReader = readline . createInterface ( {
116- input : spotlightProcess . stderr ! ,
120+ input : spotlightProcess . stderr ,
117121 crlfDelay : Infinity ,
118122 } ) ;
119123
@@ -128,9 +132,7 @@ export async function startSpotlight(options: SpotlightOptions = {}): Promise<Sp
128132 // - "http://localhost:8969"
129133 // - "port: 8969"
130134 const portMatch =
131- line . match ( / l i s t e n i n g o n ( \d + ) / i) ||
132- line . match ( / l o c a l h o s t : ( \d + ) / i) ||
133- line . match ( / p o r t [: \s] + ( \d + ) / i) ;
135+ line . match ( / l i s t e n i n g o n ( \d + ) / i) || line . match ( / l o c a l h o s t : ( \d + ) / i) || line . match ( / p o r t [: \s] + ( \d + ) / i) ;
134136
135137 if ( portMatch ?. [ 1 ] && ! resolvedPort ) {
136138 resolvedPort = parseInt ( portMatch [ 1 ] , 10 ) ;
@@ -154,7 +156,7 @@ export async function startSpotlight(options: SpotlightOptions = {}): Promise<Sp
154156
155157 // Parse stdout for JSON events
156158 const stdoutReader = readline . createInterface ( {
157- input : spotlightProcess . stdout ! ,
159+ input : spotlightProcess . stdout ,
158160 crlfDelay : Infinity ,
159161 } ) ;
160162
0 commit comments