Skip to content

Commit

Permalink
Fix Dir.glob with backslash paths on Windows.
Browse files Browse the repository at this point in the history
  • Loading branch information
nex3 committed May 4, 2012
1 parent 7536aee commit 3ee3411
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
1 change: 1 addition & 0 deletions doc-src/SASS_CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
* Support bare interpolation in the value portion of attribute
selectors (e.g. `[name=#{$value}]`).
* Support keyword arguments for the `invert()` function.
* Handle backslash-separated paths better on Windows.

## 3.1.16

Expand Down
4 changes: 2 additions & 2 deletions lib/sass/exec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ def split_colon_path(path)
def probably_dest_dir?(path)
return false unless path
return false if colon_path?(path)
return Dir.glob(File.join(path, "*.s[ca]ss")).empty?
return Sass::Util.glob(File.join(path, "*.s[ca]ss")).empty?
end
end

Expand Down Expand Up @@ -584,7 +584,7 @@ def process_directory
end

ext = @options[:from]
Dir.glob("#{@options[:input]}/**/*.#{ext}") do |f|
Sass::Util.glob("#{@options[:input]}/**/*.#{ext}") do |f|
output =
if @options[:in_place]
f
Expand Down
2 changes: 1 addition & 1 deletion lib/sass/plugin/compiler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ def update_stylesheets(individual_files = [])
staleness_checker = StalenessChecker.new(engine_options)

template_location_array.each do |template_location, css_location|
Dir.glob(File.join(template_location, "**", "[^_]*.s[ca]ss")).sort.each do |file|
Sass::Util.glob(File.join(template_location, "**", "[^_]*.s[ca]ss")).sort.each do |file|
# Get the relative path to the file
name = file.sub(template_location.to_s.sub(/\/*$/, '/'), "")
css = css_filename(name, css_location)
Expand Down
8 changes: 8 additions & 0 deletions lib/sass/util.rb
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,14 @@ def ironruby?
RUBY_ENGINE == "ironruby"
end

# Like `Dir.glob`, but works with backslash-separated paths on Windows.
#
# @param path [String]
def glob(path)
path = path.gsub('\\', '/') if windows?
Dir.glob(path)
end

## Cross-Ruby-Version Compatibility

# Whether or not this is running under Ruby 1.8 or lower.
Expand Down

0 comments on commit 3ee3411

Please sign in to comment.