Browse Source

Change order of commands returned by browser to prioritize commands used to open browsers on windows and mac (#419)

Change order of commands returned by browser to prioritize commands used to open browsers on windows and mac
Margaret Nolan 6 years ago
parent
commit
e027b505a0
1 changed files with 6 additions and 5 deletions
  1. 6
    5
      internal/driver/commands.go

+ 6
- 5
internal/driver/commands.go View File

336
 }
336
 }
337
 
337
 
338
 // browsers returns a list of commands to attempt for web visualization.
338
 // browsers returns a list of commands to attempt for web visualization.
339
-// Commands which definitely will open a browser are prioritized over other
340
-// commands like xdg-open,  which may not open the javascript embedded SVG
341
-// files produced by the -web command in a browser.
342
 func browsers() []string {
339
 func browsers() []string {
343
 	var cmds []string
340
 	var cmds []string
344
 	if userBrowser := os.Getenv("BROWSER"); userBrowser != "" {
341
 	if userBrowser := os.Getenv("BROWSER"); userBrowser != "" {
345
 		cmds = append(cmds, userBrowser)
342
 		cmds = append(cmds, userBrowser)
346
 	}
343
 	}
347
-	cmds = append(cmds, []string{"chrome", "google-chrome", "chromium", "firefox"}...)
348
 	switch runtime.GOOS {
344
 	switch runtime.GOOS {
349
 	case "darwin":
345
 	case "darwin":
350
 		cmds = append(cmds, "/usr/bin/open")
346
 		cmds = append(cmds, "/usr/bin/open")
351
 	case "windows":
347
 	case "windows":
352
 		cmds = append(cmds, "cmd /c start")
348
 		cmds = append(cmds, "cmd /c start")
353
 	default:
349
 	default:
350
+		// Commands opening browsers are prioritized over xdg-open, so browser()
351
+		// command can be used on linux to open the .svg file generated by the -web
352
+		// command (the .svg file includes embedded javascript so is best viewed in
353
+		// a browser).
354
+		cmds = append(cmds, []string{"chrome", "google-chrome", "chromium", "firefox", "sensible-browser"}...)
354
 		if os.Getenv("DISPLAY") != "" {
355
 		if os.Getenv("DISPLAY") != "" {
356
+			// xdg-open is only for use in a desktop environment.
355
 			cmds = append(cmds, "xdg-open")
357
 			cmds = append(cmds, "xdg-open")
356
 		}
358
 		}
357
-		cmds = append(cmds, "sensible-browser")
358
 	}
359
 	}
359
 	return cmds
360
 	return cmds
360
 }
361
 }