Skip to content
This repository has been archived by the owner on Jul 24, 2024. It is now read-only.

Commit

Permalink
Add support for index imports
Browse files Browse the repository at this point in the history
  • Loading branch information
xzyfer committed Mar 27, 2018
1 parent b866ad5 commit 3af837c
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,8 @@ namespace Sass {
// (2) underscore + given
// (3) underscore + given + extension
// (4) given + extension
// (5) given + _index.scss
// (6) given + _index.sass
std::vector<Include> resolve_includes(const std::string& root, const std::string& file, const std::vector<std::string>& exts)
{
std::string filename = join_paths(root, file);
Expand Down Expand Up @@ -351,6 +353,25 @@ namespace Sass {
abs_path = join_paths(root, rel_path);
if (file_exists(abs_path)) includes.push_back({{ rel_path, root }, abs_path });
}
// index files
if (includes.size() == 0) {
// ignore directories that look like @import'able filename
for(auto ext : exts) {
if (ends_with(name, ext)) return includes;
}
// next test underscore index exts
for(auto ext : exts) {
rel_path = join_paths(base, join_paths(name, "_index" + ext));
abs_path = join_paths(root, rel_path);
if (file_exists(abs_path)) includes.push_back({{ rel_path, root }, abs_path });
}
// next test plain index exts
for(auto ext : exts) {
rel_path = join_paths(base, join_paths(name, "index" + ext));
abs_path = join_paths(root, rel_path);
if (file_exists(abs_path)) includes.push_back({{ rel_path, root }, abs_path });
}
}
// nothing found
return includes;
}
Expand Down

0 comments on commit 3af837c

Please sign in to comment.