Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions webdev/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 2.0.1

- Fix launching Chrome on Windows.

## 2.0.0

## Breaking Changes
Expand Down
15 changes: 14 additions & 1 deletion webdev/lib/src/serve/chrome.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,27 @@ const _linuxExecutable = 'google-chrome';
const _macOSExecutable =
'/Applications/Google Chrome.app/Contents/MacOS/Google Chrome';
const _windowsExecutable = r'Google\Chrome\Application\chrome.exe';
var _windowsPrefixes = [
Platform.environment['LOCALAPPDATA'],
Platform.environment['PROGRAMFILES'],
Platform.environment['PROGRAMFILES(X86)']
];

String get _executable {
if (Platform.environment.containsKey(_chromeEnvironment)) {
return Platform.environment[_chromeEnvironment];
}
if (Platform.isLinux) return _linuxExecutable;
if (Platform.isMacOS) return _macOSExecutable;
if (Platform.isWindows) return _windowsExecutable;
if (Platform.isWindows) {
return p.join(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't support configuration of the windows executable location so that code snippet doesn't make sense. If you want to override the Chrome location you use the ChromeEnvironment variable.

_windowsPrefixes.firstWhere((prefix) {
if (prefix == null) return false;
var path = p.join(prefix, _windowsExecutable);
return File(path).existsSync();
}, orElse: () => '.'),
_windowsExecutable);
}
throw StateError('Unexpected platform type.');
}

Expand Down
Loading