Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Account for a file that match 2 or more patterns. #231

Merged
merged 1 commit into from
Oct 17, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/rake/file_list.rb
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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