Permalink
Browse files

warn when changed paths are directories

Simply ignoring this case may be sufficient, but we'll leave it as a
warning for now. This should address #14.
  • Loading branch information...
1 parent 68df054 commit ddf2642a763f104bc73a14f93a80c651c6a4cca2 @marcisme committed May 3, 2013
Showing with 22 additions and 1 deletion.
  1. +10 −1 lib/guard/copy.rb
  2. +12 −0 spec/guard/copy_spec.rb
View
@@ -57,7 +57,7 @@ def run_on_changes(paths)
end
validate_to_path(to_path)
UI.info("copying to #{to_path}") if options[:verbose]
- FileUtils.cp(from_path, to_path)
+ copy(from_path, to_path)
end
end
@@ -184,5 +184,14 @@ def display_target_paths
end
end
+ def copy(from_path, to_path)
+ begin
+ FileUtils.cp(from_path, to_path)
+ rescue Errno::EISDIR
+ UI.warning("matched path is a directory; skipping")
+ UI.warning(" #{ from_path }")
+ end
+ end
+
end
end
View
@@ -267,6 +267,18 @@ module Guard
File.should be_file('t2/foo')
end
+ it 'warns when a directory containing a "." is changed' do
+ dir('source/dotted.name')
+ dir('target/dotted.name')
+ guard = Copy.new([], :from => 'source', :to => 'target')
+ guard.start
+
+ UI.should_receive(:warning).with('matched path is a directory; skipping')
+ UI.should_receive(:warning).with(' source/dotted.name')
+
+ guard.run_on_changes(['source/dotted.name'])
+ end
+
context 'when :absolute is true' do
it 'copies files to absolute paths' do
file('source/foo')

0 comments on commit ddf2642

Please sign in to comment.