Skip to content

Commit

Permalink
fix: Add support for glob sort
Browse files Browse the repository at this point in the history
  • Loading branch information
bcg00ding committed Dec 10, 2024
1 parent 8fbfac2 commit 61c0d71
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/fakefs/dir.rb
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def self.foreach(dirname, &_block)
end
end

def self.glob(pattern, _flags = 0, flags: _flags, base: nil, &block) # rubocop:disable Lint/UnderscorePrefixedVariableName
def self.glob(pattern, _flags = 0, flags: _flags, base: nil, sort: true, &block) # rubocop:disable Lint/UnderscorePrefixedVariableName
pwd = FileSystem.normalize_path(base || Dir.pwd)
matches_for_pattern = lambda do |matcher|
[FileSystem.find_with_glob(matcher, flags, true, dir: pwd) || []].flatten.map do |e|
Expand All @@ -138,9 +138,11 @@ def self.glob(pattern, _flags = 0, flags: _flags, base: nil, &block) # rubocop:d
else
e.to_s.match(pwd_regex).post_match
end
end.sort
end
end

matches_for_pattern.sort! if sort

files =
if pattern.is_a?(Array)
pattern.map do |matcher|
Expand Down

0 comments on commit 61c0d71

Please sign in to comment.