Created
August 23, 2022 21:57
-
-
Save midwire/0505c81b25534b7ab8debdd048f504be to your computer and use it in GitHub Desktop.
[Capistrano - detect if a remote file exists] #ruby
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def file_exists?(path) | |
capture(:ls, path) | |
true | |
rescue SSHKit::Command::Failed | |
false | |
end | |
def state_page | |
stage = fetch(:stage) | |
parts = stage.to_s.split('_') | |
"#{parts.first}.html" | |
end | |
def static_maintenance_page(root_path) | |
custom = File.join(root_path, 'lib', 'maintenance', state_page) | |
return custom if file_exists?(custom) | |
File.join(root_path, 'lib', 'maintenance', 'maintenance.html') | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment