lib/makit/directory.rb in makit-0.0.2 vs lib/makit/directory.rb in makit-0.0.3

- old
+ new

@@ -136,14 +136,16 @@ # for a given path, return the filename of the most recently modified file def self.get_newest_file(path) newest_file = nil latest_date = nil - Find.find(path) do |file| - if File.file?(file) - date = File.mtime(file) - latest_date = date if latest_date.nil? || date > latest_date - newest_file = file if date == latest_date + if (Dir.exist?(path)) + Find.find(path) do |file| + if File.file?(file) + date = File.mtime(file) + latest_date = date if latest_date.nil? || date > latest_date + newest_file = file if date == latest_date + end end end newest_file end end