augustash / capistrano-ash

August Ash recipes for Capistrano
http://augustash.com
MIT License
73 stars 12 forks source link

add support for different htaccess file per environment #23

Closed martensc closed 12 years ago

martensc commented 12 years ago

something like this may work:

# --------------------------------------------
# Overridden Tasks
# --------------------------------------------
namespace :ash do
    desc 'Copy distribution htaccess file'
    task :htaccess, :roles => :web do
        htaccess_env_file = "htacces.#{stage}.dist"
        if remote_file_exists?("#{latest_release}/#{htaccess_env_file}")
            run "mv #{latest_release}/#{htaccess_env_file} #{latest_release}/.htaccess"
        else 
            run "mv #{latest_release}/htaccess.dist #{latest_release}/.htaccess" if remote_file_exists?("#{latest_release}/htaccess.dist")
        end
  end
end
grafikchaos commented 12 years ago
# --------------------------------------------
# capistrano-ash ASH overridden tasks
# --------------------------------------------
namespace :ash do
  desc 'Copy distribution htaccess file'
  task :htaccess, :roles => :web do
    case true
    when remote_file_exists?("#{latest_release}/htaccess.#{stage}.dist")
      run "mv #{latest_release}/htaccess.#{stage}.dist #{latest_release}/.htaccess"
    when remote_file_exists?("#{latest_release}/htaccess.#{stage}")
      run "mv #{latest_release}/htaccess.#{stage} #{latest_release}/.htaccess"
    when remote_file_exists?("#{latest_release}/htaccess.dist")
      run "mv #{latest_release}/htaccess.dist #{latest_release}/.htaccess"
    else
      logger.important "Failed to move the .htaccess file in #{latest_release} because an unknown pattern was used"
    end
  end
end