Skip to content

Commit 60bd4d5

Browse files
author
Andrea Nodari
committed
Fix bug when a file_clash arise
In some cases creating a file would raise an exception, due to clashes with existing file. E.g. creating a file where a directory with the same name is present. This fix rescue the exception and print a "file_clash" warning.
1 parent 71f6f54 commit 60bd4d5

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

lib/thor/actions/empty_directory.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,17 @@ def invoke_with_conflict_check(&block)
112112
if exists?
113113
on_conflict_behavior(&block)
114114
else
115-
say_status :create, :green
116115
yield unless pretend?
116+
say_status :create, :green
117117
end
118118

119119
destination
120+
rescue Errno::EISDIR, Errno::EEXIST
121+
on_file_clash_behavior
122+
end
123+
124+
def on_file_clash_behavior
125+
say_status :file_clash, :red
120126
end
121127

122128
# What to do when the destination file already exists.

0 commit comments

Comments
 (0)