mirror of
https://github.com/discourse/discourse.git
synced 2024-12-05 10:15:47 +08:00
7b31d8a11b
We had checks for the chrome binary in 3 different places for tests and only one of them checked for google-chrome-stable, which is problematic for Arch linux users (there are dozens of us!) This PR moves all the code to one place and references it instead of copying and pasting.
26 lines
860 B
Ruby
26 lines
860 B
Ruby
# frozen_string_literal: true
|
|
|
|
require "rbconfig"
|
|
|
|
class ChromeInstalledChecker
|
|
class ChromeNotInstalled < StandardError; end
|
|
class ChromeVersionTooLow < StandardError; end
|
|
|
|
def self.run
|
|
if RbConfig::CONFIG['host_os'][/darwin|mac os/]
|
|
binary = "/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome"
|
|
elsif system("command -v google-chrome-stable >/dev/null;")
|
|
binary = "google-chrome-stable"
|
|
end
|
|
binary ||= "google-chrome" if system("command -v google-chrome >/dev/null;")
|
|
|
|
if !binary
|
|
raise ChromeNotInstalled.new("Chrome is not installed. Download from https://www.google.com/chrome/browser/desktop/index.html")
|
|
end
|
|
|
|
if Gem::Version.new(`\"#{binary}\" --version`.match(/[\d\.]+/)[0]) < Gem::Version.new("59")
|
|
raise ChromeVersionTooLow.new("Chrome 59 or higher is required")
|
|
end
|
|
end
|
|
end
|