Skip to content

Commit

Permalink
Fix chromium version fetcher (#2654)
Browse files Browse the repository at this point in the history
  • Loading branch information
kblok authored Jun 6, 2024
1 parent 3a2a395 commit 42b1fd0
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
10 changes: 7 additions & 3 deletions lib/PuppeteerSharp/BrowserFetcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,13 @@ public async Task<bool> CanDownloadAsync(string revision)
/// <inheritdoc/>
public async Task<InstalledBrowser> DownloadAsync()
{
var buildId = Browser == SupportedBrowser.Firefox
? await Firefox.GetDefaultBuildIdAsync().ConfigureAwait(false)
: Chrome.DefaultBuildId;
var buildId = Browser switch
{
SupportedBrowser.Firefox => await Firefox.GetDefaultBuildIdAsync().ConfigureAwait(false),
SupportedBrowser.Chrome or SupportedBrowser.ChromeHeadlessShell => Chrome.DefaultBuildId,
SupportedBrowser.Chromium => await Chromium.ResolveBuildIdAsync(Platform).ConfigureAwait(false),
_ => throw new PuppeteerException($"{Browser} not supported."),
};

return await DownloadAsync(buildId).ConfigureAwait(false);
}
Expand Down
11 changes: 8 additions & 3 deletions lib/PuppeteerSharp/Launcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,14 @@ public async Task<IBrowser> LaunchAsync(LaunchOptions options)

EnsureSingleLaunchOrConnect();
_browser = options.Browser;
var executable = options.ExecutablePath ?? GetExecutablePath(
options,
options.Browser == SupportedBrowser.Firefox ? await Firefox.GetDefaultBuildIdAsync().ConfigureAwait(false) : Chrome.DefaultBuildId);
var buildId = options.Browser switch
{
SupportedBrowser.Firefox => await Firefox.GetDefaultBuildIdAsync().ConfigureAwait(false),
SupportedBrowser.Chrome or SupportedBrowser.ChromeHeadlessShell => Chrome.DefaultBuildId,
SupportedBrowser.Chromium => await Chromium.ResolveBuildIdAsync(BrowserFetcher.GetCurrentPlatform()).ConfigureAwait(false),
_ => throw new ArgumentException("Invalid browser"),
};
var executable = options.ExecutablePath ?? GetExecutablePath(options, buildId);

Process = options.Browser switch
{
Expand Down
6 changes: 3 additions & 3 deletions lib/PuppeteerSharp/PuppeteerSharp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
<Description>Headless Browser .NET API</Description>
<PackageId>PuppeteerSharp</PackageId>
<PackageReleaseNotes></PackageReleaseNotes>
<PackageVersion>18.0.0</PackageVersion>
<ReleaseVersion>18.0.0</ReleaseVersion>
<AssemblyVersion>18.0.0</AssemblyVersion>
<PackageVersion>18.0.1</PackageVersion>
<ReleaseVersion>18.0.1</ReleaseVersion>
<AssemblyVersion>18.0.1</AssemblyVersion>
<FileVersion>18.0.0</FileVersion>
<SynchReleaseVersion>false</SynchReleaseVersion>
<StyleCopTreatErrorsAsWarnings>false</StyleCopTreatErrorsAsWarnings>
Expand Down

0 comments on commit 42b1fd0

Please sign in to comment.