Skip to content

Commit

Permalink
Strip out './' when looking up relative @imports.
Browse files Browse the repository at this point in the history
This was causing JRuby to choke on templates in a jar importing each other.

Relevant Stack Overflow question: http://stackoverflow.com/questions/8236327/getting-file-not-found-error-running-sass-and-compass-as-jar-in-ant

Closes #583
  • Loading branch information
ahcodedthat authored and nex3 committed Nov 30, 2012
1 parent 62f21c5 commit 9c95538
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
5 changes: 5 additions & 0 deletions doc-src/SASS_CHANGELOG.md
Expand Up @@ -3,6 +3,11 @@
* Table of contents
{:toc}

## 3.2.4 (Unreleased)

* Fix imports from `.jar` files in JRuby. Thanks to [Alex
Hvostov](https://github.com/argv-minus-one).

## 3.2.3

* `sass --watch` no longer crashs when a file in a watched directory is deleted.
Expand Down
12 changes: 9 additions & 3 deletions lib/sass/importers/filesystem.rb
Expand Up @@ -91,8 +91,14 @@ def possible_files(name)
sorted_exts = extensions.sort
syntax = extensions[extname]

return [["#{dirname}/{_,}#{basename}.#{extensions.invert[syntax]}", syntax]] if syntax
sorted_exts.map {|ext, syn| ["#{dirname}/{_,}#{basename}.#{ext}", syn]}
if syntax
ret = [["#{dirname}/{_,}#{basename}.#{extensions.invert[syntax]}", syntax]]
else
ret = sorted_exts.map {|ext, syn| ["#{dirname}/{_,}#{basename}.#{ext}", syn]}
end

# JRuby chokes when trying to import files from JARs when the path starts with './'.
ret.map {|f, s| [f.sub(%r{^\./}, ''), s]}
end

def escape_glob_characters(name)
Expand All @@ -118,7 +124,7 @@ def find_real_file(dir, name, options)
end
found = Sass::Util.flatten(found, 1)
return if found.empty?

if found.size > 1 && !@same_name_warnings.include?(found.first.first)
found.each {|(f, _)| @same_name_warnings << f}
relative_to = Pathname.new(dir)
Expand Down

0 comments on commit 9c95538

Please sign in to comment.