Skip to content

Commit

Permalink
Adding additional Chrome environment variables for executable resolut…
Browse files Browse the repository at this point in the history
…ion. (dart-archive/browser_launcher#24)

* Adding additional Chrome environment variables to executable resolution.

* Updating changelog and version
  • Loading branch information
Markzipan authored Mar 18, 2021
1 parent cb4ab86 commit 0e93231
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
4 changes: 4 additions & 0 deletions pkgs/browser_launcher/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.1.9

- Add support for Chrome executables in `CHROME_PATH`.

## 0.1.8

- Log `STDERR` on Chrome launch failure.
Expand Down
8 changes: 5 additions & 3 deletions pkgs/browser_launcher/lib/src/chrome.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,17 @@ import 'dart:io';
import 'package:path/path.dart' as p;
import 'package:webkit_inspection_protocol/webkit_inspection_protocol.dart';

const _chromeEnvironment = 'CHROME_EXECUTABLE';
const _chromeEnvironments = ['CHROME_EXECUTABLE', 'CHROME_PATH'];
const _linuxExecutable = 'google-chrome';
const _macOSExecutable =
'/Applications/Google Chrome.app/Contents/MacOS/Google Chrome';
const _windowsExecutable = r'Google\Chrome\Application\chrome.exe';

String get _executable {
if (Platform.environment.containsKey(_chromeEnvironment)) {
return Platform.environment[_chromeEnvironment];
for (var chromeEnv in _chromeEnvironments) {
if (Platform.environment.containsKey(chromeEnv)) {
return Platform.environment[chromeEnv];
}
}
if (Platform.isLinux) return _linuxExecutable;
if (Platform.isMacOS) return _macOSExecutable;
Expand Down
2 changes: 1 addition & 1 deletion pkgs/browser_launcher/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: browser_launcher
description: Provides a standardized way to launch web browsers for testing and tools.

version: 0.1.8
version: 0.1.9

homepage: https://github.com/dart-lang/browser_launcher

Expand Down

0 comments on commit 0e93231

Please sign in to comment.