@@ -200,15 +200,21 @@ export async function withHeadlessBrowser<T>(
200200 }
201201}
202202
203- export async function findChrome ( ) : Promise < string | undefined > {
203+ interface ChromeInfo {
204+ path : string | undefined ;
205+ source : string | undefined ;
206+ }
207+
208+ export async function findChrome ( ) : Promise < ChromeInfo > {
204209 let path ;
210+ let source ;
205211 // First check env var and use this path if specified
206212 const envPath = Deno . env . get ( "QUARTO_CHROMIUM" ) ;
207213 if ( envPath ) {
208214 debug ( "[CHROMIUM] Using path specified in QUARTO_CHROMIUM" ) ;
209215 if ( safeExistsSync ( envPath ) ) {
210216 debug ( `[CHROMIUM] Found at ${ envPath } , and will be used.` ) ;
211- return envPath ;
217+ return { path : envPath , source : "QUARTO_CHROMIUM" } ;
212218 } else {
213219 debug (
214220 `[CHROMIUM] Not found at ${ envPath } . Check your environment variable valye. Searching now for another binary.` ,
@@ -222,6 +228,7 @@ export async function findChrome(): Promise<string | undefined> {
222228 "/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge" ,
223229 ] ;
224230 path = programs . find ( safeExistsSync ) ;
231+ source = "MacOS known location" ;
225232 } else if ( isWindows ) {
226233 // Try the HKLM key
227234 const programs = [ "chrome.exe" , "msedge.exe" ] ;
@@ -231,7 +238,10 @@ export async function findChrome(): Promise<string | undefined> {
231238 programs [ i ] ,
232239 "(Default)" ,
233240 ) ;
234- if ( path && safeExistsSync ( path ) ) break ;
241+ if ( path && safeExistsSync ( path ) ) {
242+ source = "Windows Registry" ;
243+ break ;
244+ }
235245 }
236246
237247 // Try the HKCR key
@@ -244,7 +254,10 @@ export async function findChrome(): Promise<string | undefined> {
244254 ) ;
245255 path = path ?. match ( / " ( .* ) " / ) ;
246256 path = path ? path [ 1 ] : undefined ;
247- if ( path && existsSync ( path ) ) break ;
257+ if ( path && existsSync ( path ) ) {
258+ source = "Windows Registry" ;
259+ break ;
260+ }
248261 }
249262 }
250263 } else {
@@ -254,14 +267,17 @@ export async function findChrome(): Promise<string | undefined> {
254267 if ( ! path ) {
255268 path = await which ( "chromium-browser" ) ;
256269 }
270+ if ( path && existsSync ( path ) ) {
271+ source = "PATH" ;
272+ }
257273 }
258274 if ( path ) {
259275 debug ( "[CHROMIUM] Found Chromium on OS known location" ) ;
260276 debug ( `[CHROMIUM] Path: ${ path } ` ) ;
261277 } else {
262278 debug ( "[CHROMIUM] Chromium not found on OS known location" ) ;
263279 }
264- return path ;
280+ return { path : path , source : source } ;
265281}
266282
267283export async function getBrowserExecutablePath ( ) {
@@ -272,7 +288,7 @@ export async function getBrowserExecutablePath() {
272288 let executablePath : string | undefined = undefined ;
273289
274290 if ( executablePath === undefined ) {
275- executablePath = await findChrome ( ) ;
291+ executablePath = ( await findChrome ( ) ) . path ;
276292 }
277293
278294 if ( executablePath === undefined && availableRevisions . length > 0 ) {
0 commit comments