module Sass::Files

def find_file_to_import(filename, load_paths)

Raises:
  • (Sass::SyntaxError) - if `filename` ends in `".sass"` or `".scss"`

Returns:
  • (String) - The filename of the imported file.

Parameters:
  • load_paths (Array) -- The set of filesystem paths
  • filename (String) -- The filename to search for
def find_file_to_import(filename, load_paths)
  was_sass = was_scss = false
  original_filename = filename
  if [".sass", ".scss"].include?(filename[-5..-1])
    was_sass = filename[-5..-1] == ".sass"
    was_scss = filename[-5..-1] == ".scss"
    filename = filename[0...-5]
  elsif filename[-4..-1] == ".css"
    return filename
  end
  new_filename = nil
  load_paths = load_paths.uniq
  load_paths.each do |load_path|
    new_filename ||= find_full_path("#{filename}.sass", load_path) unless was_scss
    new_filename ||= find_full_path("#{filename}.scss", load_path) unless was_sass
  end
  return new_filename if new_filename
  unless was_sass || was_scss
    Haml::Util.haml_warn <<END
ING: Neither #{filename}.sass nor .scss found. Using #{filename}.css instead.
 behavior is deprecated and will be removed in a future version.
ou really need #{filename}.css, import it explicitly.
    return filename + '.css'
  end
  message = "File to import not found or unreadable: #{original_filename}.\n"
  if load_paths.size == 1
    message << "Load path: #{load_paths.first}"
  else
    message << "Load paths:\n  " << load_paths.join("\n  ")
  end
  raise SyntaxError.new(message)
end