lib/guard/jekyll-plus.rb in guard-jekyll-plus-1.4.6 vs lib/guard/jekyll-plus.rb in guard-jekyll-plus-1.4.7

- old
+ new

@@ -162,37 +162,40 @@ end # Remove deleted source file/directories from destination # def remove(files=[]) - begin - message = 'removed file' - message += 's' if files.size > 1 - UI.info "#{@msg_prefix} #{message.red}" unless @config[:silent] - puts '| ' #spacing + # Ensure at least one file still exists (other scripts may clean up too) + if files.select {|f| File.exist? f }.size > 0 + begin + message = 'removed file' + message += 's' if files.size > 1 + UI.info "#{@msg_prefix} #{message.red}" unless @config[:silent] + puts '| ' #spacing - files.each do |file| - path = destination_path file - if File.exist? path - FileUtils.rm path - puts '|' + " x ".red + path - end + files.each do |file| + path = destination_path file + if File.exist? path + FileUtils.rm path + puts '|' + " x ".red + path + end - dir = File.dirname path - if Dir[dir+'/*'].empty? - FileUtils.rm_r(dir) - puts '|' + " x ".red + dir + dir = File.dirname path + if Dir[dir+'/*'].empty? + FileUtils.rm_r(dir) + puts '|' + " x ".red + dir + end end - end - puts '| ' #spacing + puts '| ' #spacing - rescue Exception => e - UI.error "#{@msg_prefix} remove has failed" unless @config[:silent] - UI.error e - stop_server - throw :task_has_failed + rescue Exception => e + UI.error "#{@msg_prefix} remove has failed" unless @config[:silent] + UI.error e + stop_server + throw :task_has_failed + end + true end - true end def jekyll_matches(paths) paths.select { |file| file =~ @extensions } end