Skip to content

Commit

Permalink
Merge pull request #231 from styd/unique-file-list
Browse files Browse the repository at this point in the history
Account for a file that match 2 or more patterns.
  • Loading branch information
hsbt committed Oct 17, 2017
2 parents f7b9689 + bfab5f8 commit f962d63
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lib/rake/file_list.rb
Expand Up @@ -318,14 +318,14 @@ def egrep(pattern, *options)
# Return a new file list that only contains file names from the current
# file list that exist on the file system.
def existing
select { |fn| File.exist?(fn) }
select { |fn| File.exist?(fn) }.uniq
end

# Modify the current file list so that it contains only file name that
# exist on the file system.
def existing!
resolve
@items = @items.select { |fn| File.exist?(fn) }
@items = @items.select { |fn| File.exist?(fn) }.uniq
self
end

Expand Down
4 changes: 2 additions & 2 deletions test/test_rake_file_list.rb
Expand Up @@ -415,13 +415,13 @@ def test_egrep_with_error
end

def test_existing
fl = FileList["abc.c", "notthere.c"]
fl = FileList["*c.c", "notthere.c", "a*.c"]
assert_equal ["abc.c"], fl.existing
assert fl.existing.is_a?(FileList)
end

def test_existing!
fl = FileList["abc.c", "notthere.c"]
fl = FileList["*c.c", "notthere.c", "a*.c"]
result = fl.existing!
assert_equal ["abc.c"], fl
assert_equal fl.object_id, result.object_id
Expand Down

0 comments on commit f962d63

Please sign in to comment.