Make sure castle dir exists before trying to link from it, preventing empty dirs from being created.
This commit is contained in:
@@ -41,18 +41,26 @@ class Homesick < Thor
|
|||||||
|
|
||||||
desc "link NAME", "Symlinks all dotfiles from the specified castle"
|
desc "link NAME", "Symlinks all dotfiles from the specified castle"
|
||||||
def link(home)
|
def link(home)
|
||||||
inside castle_dir(home) do
|
unless castle_dir(home).exist?
|
||||||
files = Pathname.glob('.*').reject{|a| [".",".."].include?(a.to_s)}
|
say_status :error, "Castle #{home} did not exist in #{repos_dir}", :red
|
||||||
files.each do |path|
|
|
||||||
absolute_path = path.expand_path
|
|
||||||
|
|
||||||
inside user_dir do
|
exit(1)
|
||||||
adjusted_path = (user_dir + path).basename
|
|
||||||
|
|
||||||
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
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
desc "list", "List cloned castles"
|
desc "list", "List cloned castles"
|
||||||
|
|||||||
Reference in New Issue
Block a user