Skip to content

Commit

Permalink
don't return directories when requesting files
Browse files Browse the repository at this point in the history
  • Loading branch information
yannlugrin committed Jun 20, 2011
1 parent f56db54 commit 043d285
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
5 changes: 2 additions & 3 deletions lib/guard/listener.rb
Expand Up @@ -47,7 +47,7 @@ def update_last_event
end end


def modified_files(dirs, options = {}) def modified_files(dirs, options = {})
files = potentially_modified_files(dirs, options).select { |path| File.file?(path) && file_modified?(path) } files = potentially_modified_files(dirs, options).select { |path| file_modified?(path) }
relativate_paths files relativate_paths files
end end


Expand Down Expand Up @@ -77,12 +77,11 @@ def relativate_paths?
!!@relativate_paths !!@relativate_paths
end end



private private


def potentially_modified_files(dirs, options = {}) def potentially_modified_files(dirs, options = {})
match = options[:all] ? "**/*" : "*" match = options[:all] ? "**/*" : "*"
Dir.glob(dirs.map { |dir| "#{dir}#{match}" }, File::FNM_DOTMATCH).select { |file| file !~ /\.\.?$/ } Dir.glob(dirs.map { |dir| "#{dir}#{match}" }, File::FNM_DOTMATCH).select { |file| File.file?(file) }
end end


# Depending on the filesystem, mtime is probably only precise to the second, so round # Depending on the filesystem, mtime is probably only precise to the second, so round
Expand Down
2 changes: 1 addition & 1 deletion spec/guard/listener_spec.rb
Expand Up @@ -42,7 +42,7 @@
subject { described_class.new(@fixture_path) } subject { described_class.new(@fixture_path) }


it "should return all files" do it "should return all files" do
subject.all_files.should =~ Dir.glob("#{@fixture_path}/**/*", File::FNM_DOTMATCH).select { |file| file !~ /\.\.?$/ } subject.all_files.should =~ Dir.glob("#{@fixture_path}/**/*", File::FNM_DOTMATCH).select { |file| File.file?(file) }
end end
end end


Expand Down

0 comments on commit 043d285

Please sign in to comment.