From 8add88a1dca905d52acdc8c2cbfe21a9528034aa Mon Sep 17 00:00:00 2001 From: Joshua Nichols Date: Wed, 17 Mar 2010 11:38:03 -0400 Subject: [PATCH] Make sure castle dir exists before trying to link from it, preventing empty dirs from being created. --- lib/homesick.rb | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/lib/homesick.rb b/lib/homesick.rb index b2e8d51..2a8b65a 100644 --- a/lib/homesick.rb +++ b/lib/homesick.rb @@ -41,18 +41,26 @@ class Homesick < Thor desc "link NAME", "Symlinks all dotfiles from the specified castle" def link(home) - inside castle_dir(home) do - files = Pathname.glob('.*').reject{|a| [".",".."].include?(a.to_s)} - files.each do |path| - absolute_path = path.expand_path + unless castle_dir(home).exist? + say_status :error, "Castle #{home} did not exist in #{repos_dir}", :red - inside user_dir do - adjusted_path = (user_dir + path).basename + exit(1) - symlink absolute_path, adjusted_path + else + inside castle_dir(home) do + files = Pathname.glob('.*').reject{|a| [".",".."].include?(a.to_s)} + files.each do |path| + absolute_path = path.expand_path + + inside user_dir do + adjusted_path = (user_dir + path).basename + + symlink absolute_path, adjusted_path + end end end end + end desc "list", "List cloned castles"