Skip to content

Commit

Permalink
Fix absolute path handling by the Filesystem importer.
Browse files Browse the repository at this point in the history
Closes sassgh-180
  • Loading branch information
nex3 committed Nov 24, 2011
1 parent 602b4ec commit fc056d7
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions doc-src/SASS_CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* Don't crash on JRuby if the underlying Java doesn't support every Unicode encoding.
* Add new `updated_stylesheet` callback, which is run after each stylesheet has
been successfully compiled. Thanks to [Christian Peters](https://github.com/ChristianPeters).
* Allow absolute paths to be used in an importer with a different root.

### Deprecations -- Must Read!

Expand Down
2 changes: 1 addition & 1 deletion lib/sass/importers/filesystem.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def escape_glob_characters(name)
# @return [(String, Symbol)] A filename-syntax pair.
def find_real_file(dir, name)
for (f,s) in possible_files(remove_root(name))
path = (dir == ".") ? f : "#{dir}/#{f}"
path = (dir == "." || Pathname.new(f).absolute?) ? f : "#{dir}/#{f}"
if full_path = Dir[path].first
full_path.gsub!(REDUNDANT_DIRECTORY,File::SEPARATOR)
return full_path, s
Expand Down
7 changes: 7 additions & 0 deletions test/sass/importer_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -176,10 +176,17 @@ def test_staleness_check_across_importers
file_system_importer
)
end

def fixture_dir
File.join(File.dirname(__FILE__), "fixtures")
end

def fixture_file(path)
File.join(fixture_dir, path)
end

def test_absolute_files_across_template_locations
importer = Sass::Importers::Filesystem.new(absolutize 'templates')
assert_not_nil importer.mtime(absolutize('more_templates/more1.sass'), {})
end
end
2 changes: 1 addition & 1 deletion test/sass/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@

class Test::Unit::TestCase
def absolutize(file)
"#{File.dirname(__FILE__)}/#{file}"
File.expand_path("#{File.dirname(__FILE__)}/#{file}")
end
end

0 comments on commit fc056d7

Please sign in to comment.