lib/chromedriver_update.rb in chromedriver_update-0.1.8 vs lib/chromedriver_update.rb in chromedriver_update-0.1.9

- old
+ new

@@ -14,12 +14,12 @@ CHROME_DOWNLOADS_LIST_URL = 'https://googlechromelabs.github.io/chrome-for-testing/known-good-versions-with-downloads.json' # # Update the installed version of chromedriver automatically fitting to the currently installed version of chrome # - def self.auto_update_chromedriver - if installed_chrome_version.split(".").first != installed_chromedriver_version.split(".").first + def self.auto_update_chromedriver(force: false) + if installed_chrome_version.split(".").first != installed_chromedriver_version.split(".").first || force original_chromedriver_version = installed_chromedriver_version chromedriver_zip = HTTParty.get(chromedriver_link_for_version(installed_chrome_version)) if chromedriver_zip.code == 404 # fallback to latest lower version chromedriver_zip = HTTParty.get(chromedriver_closest_link_for_version(installed_chrome_version)) end @@ -30,9 +30,19 @@ if (entry.name.end_with?("/chromedriver") || entry.name.end_with?("/chromedriver.exe")) download_path = File.join(destination_dir, File.basename(entry.name)) FileUtils.rm_f(download_path) entry.extract(download_path) FileUtils.mv(download_path, chromedriver_path, force: true) + begin + FileUtils.chmod("+x", chromedriver_path) + rescue + unless OS.windows? + begin + `sudo chmod +x "#{chromedriver_path}"` + rescue + end + end + end end end end puts "Updated Chromedriver from '#{original_chromedriver_version}' to '#{installed_chromedriver_version}'! Chrome is '#{installed_chrome_version}'." else