Skip to content

Commit

Permalink
Separate out deprecated import file extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
xzyfer committed Mar 24, 2018
1 parent 77f1323 commit b9662fc
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
14 changes: 13 additions & 1 deletion src/file.cpp
Expand Up @@ -323,7 +323,7 @@ namespace Sass {
// (2) underscore + given
// (3) underscore + given + extension
// (4) given + extension
std::vector<Include> resolve_includes(const std::string& root, const std::string& file, const std::vector<std::string>& exts)
std::vector<Include> resolve_includes(const std::string& root, const std::string& file, const std::vector<std::string>& exts, const std::vector<std::string>& d_exts)
{
std::string filename = join_paths(root, file);
// split the filename
Expand All @@ -350,6 +350,18 @@ namespace Sass {
abs_path = join_paths(root, rel_path);
if (file_exists(abs_path)) includes.push_back({{ rel_path, root }, abs_path });
}
// next test d_exts plus underscore
for(auto ext : d_exts) {
rel_path = join_paths(base, "_" + name + ext);
abs_path = join_paths(root, rel_path);
if (file_exists(abs_path)) includes.push_back({{ rel_path, root }, abs_path });
}
// next test plain name with d_exts
for(auto ext : d_exts) {
rel_path = join_paths(base, name + 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
6 changes: 4 additions & 2 deletions src/file.hpp
Expand Up @@ -121,10 +121,12 @@ namespace Sass {

namespace File {

static std::vector<std::string> defaultExtensions = { ".scss", ".sass", ".css" };
static std::vector<std::string> defaultExtensions = { ".scss", ".sass" };
static std::vector<std::string> deprecatedExtensions = { ".css" };

std::vector<Include> resolve_includes(const std::string& root, const std::string& file,
const std::vector<std::string>& exts = defaultExtensions);
const std::vector<std::string>& exts = defaultExtensions,
const std::vector<std::string>& d_exts = deprecatedExtensions);

}

Expand Down

0 comments on commit b9662fc

Please sign in to comment.