Skip to content

Instantly share code, notes, and snippets.

@bestlong
Last active August 29, 2015 14:23
Show Gist options
  • Save bestlong/638402be69649ddac181 to your computer and use it in GitHub Desktop.
Save bestlong/638402be69649ddac181 to your computer and use it in GitHub Desktop.
Touches all linked files if not exist, use Capistrano 3.4.0
### part of config/deploy.rb
namespace :deploy do
namespace :check do
# desc 'Touches all linked files'
task :touch_all_linked_files do
on release_roles :all do
fetch(:linked_files, []).each do |file|
target = shared_path.join(file)
unless File.file?(target)
info "File.file?('#{target}') : #{File.file?(target)}"
execute :touch, target
info "Touched : #{target}"
end
end
end
end
end
before 'deploy:check:linked_files', 'deploy:check:touch_all_linked_files'
end
@bestlong
Copy link
Author

File.file?() is running at local, not remote, so always get false.
need change to above:
unless test("[ -f #{target} ]")
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment