问题
Right now in Capistrano I have it doing
execute "echo #{fetch(:stage)}"
Which echoes out "staging"
On the very next line I have
if fetch(:stage) == "staging"
Which never equals true. I tried changing it to if "staging == "staging" and it enters the body of it. Uh, what gives and how do I do a check to only run one line of code for staging.
回答1:
fetch(:stage) is likely a symbol (it's been a while since I used capistrano). To verify this, use a more precise string representation:
execute "echo #{fetch(:stage).inspect}"
I'm betting it will print :staging. In which case you need to do
if fetch(:stage) == :staging
来源:https://stackoverflow.com/questions/49677374/how-to-add-an-if-staging-check-to-capistrano-task