lib/chicken_soup/capabilities/unix.rb in chicken_soup-0.0.2 vs lib/chicken_soup/capabilities/unix.rb in chicken_soup-0.0.3
- old
+ new
@@ -7,23 +7,32 @@
namespace :deploy do
namespace :config do
desc <<-DESC
Creates the directory where the `symlink` task will look for its configuration files.
- It will first look in the user's home directory to see if there is
- a file of the same name as one of the shared files. If there is, it
- will move that to the shared location. If not, it will create an
- empty file.
+ It will first look in the local Rails directory to see if there is
+ a file of the same name as one of the shared files with the deployment environment
+ appended on the end.
+
+ For example, if you had `config/database.yml` as one of your global_shared_files and
+ you were deploying to the `staging` environment, this task will look for:
+
+ #{Rails.root}/config/database.yml.staging
+
+ If it finds it, it will upload the file to the shared directory on the server.
+
+ If it doesn't find it, it will check to see if the remote file exists and finally,
+ if not, it will just create an empty file.
DESC
task :create do
run "if [ ! -d #{shared_path}/config ]; then mkdir -p #{shared_path}/config; fi"
global_shared_files.each do |shared_file|
- local_shared_file = "#{shared_file}.#{rails_env}"
+ local_shared_file = "#{Dir.pwd}/#{shared_file}.#{rails_env}"
if File.exists?(local_shared_file)
top.upload(local_shared_file, "#{shared_path}/#{shared_file}", :mode => "600")
- else
+ elsif !remote_file_exists?("#{shared_path}/#{shared_file}")
run "touch #{shared_path}/#{shared_file}"
end
end
end