lib/percy/capybara/loaders/base_loader.rb in percy-capybara-3.0.0 vs lib/percy/capybara/loaders/base_loader.rb in percy-capybara-3.0.1

- old
+ new

@@ -1,5 +1,6 @@ +require 'pathname' require 'percy/capybara' module Percy module Capybara module Loaders @@ -122,13 +123,11 @@ end def _resources_from_dir(root_dir, base_url: '/') resources = [] - Find.find(root_dir).each do |path| - # Skip directories. - next unless FileTest.file?(path) + _find_files(root_dir).each do |path| # Skip certain extensions. next if SKIP_RESOURCE_EXTENSIONS.include?(File.extname(path)) # Skip large files, these are hopefully downloads and not used in page rendering. next if File.size(path) > MAX_FILESIZE_BYTES @@ -139,9 +138,24 @@ resources << Percy::Client::Resource.new(resource_url, sha: sha, path: path) end resources + end + + # A simplified version of Find.find that only returns files and follows symlinks. + def _find_files(*paths) + paths.flatten! + paths.map! { |p| Pathname.new(p) } + files = [] + paths.each do |path| + if path.file? + files << path.to_s + else + files = files.concat(_find_files(path.children)) + end + end + files end def _uri_join(*paths) # We must swap File::SEPARATOR for '/' here because on Windows File.join # will use backslashes and this is a URL.