Created
February 4, 2013 01:41
-
-
Save chrisirhc/4704595 to your computer and use it in GitHub Desktop.
A function to resolve sass dependencies. Might come in handy with the grunt sass plugin. This is from guard-sass reference to: https://github.com/hawx/guard-sass/pull/31
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def resolve_partials_to_owners(paths) | |
# Get all files that might have imports | |
root = (options[:input][-1] == "/" ? options[:input] : "#{options[:input]}/").reverse | |
search_files = Dir.glob("#{options[:input]}/**/*.s[ac]ss") | |
search_files = Watcher.match_files(self, search_files) | |
# Get owners | |
owners = search_files.select do |file| | |
# Get dependencies of file | |
deps = Sass::Engine.for_file(file, {}).dependencies.collect! {|dep| dep.options[:filename]} | |
# Find intersection with paths | |
deps_in_paths = deps.intersection paths | |
# Any paths in the dependencies? | |
!deps_in_paths.empty? | |
end | |
# Return our resolved set of paths to recompile | |
paths + owners | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment