Closed cheald closed 12 years ago
Wow. Thanks, this is great. The dependency resolution is much faster.
I've just changed @include …
searching to be more flexible, it will check for underscores and/or extension as well as without.
I actually had it with the underscores and extensions first (you can see that in my earlier commits), then moved to the much more general regex. You're actually right in adding the underscores (oops!), but that should be a simple tweak to the regex. The extension shouldn't be necessary, though, since it's not an anchored search, but I suppose they can't hurt! :)
My thoughts exactly.
Just curious, why isn't this using the built-in Sass::Engine#dependencies method instead of looking through the files to find the dependencies? It can use that to create a map iterate through the maps.
Sass::Engine#dependencies
returns the files it imports, not that import it (if that is clear). So the current method can be thought of as the reverse of #dependencies
.
Yep.
What I mean is to use the dependencies method on each search_file
file instead of recursively searching the import tree. Why not just use the built-in method dependencies method and check if the the current file is in that list for each search file?
Something like:
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
I could send a pull request, but I'm wondering if there's a reason for not doing this instead. There's no need to walk the dependencies because it is already flattened by Sass::Engine
.
I get what you mean now. It looks good. If you send me a pull request I'd be happy to accept it.
Big series of changes here, so I understand if the pull request is rejected, but I tried to keep them atomic.
I:
foo -> _bar -> _baz
, and change_baz
, it'll figure out to recompilefoo
(as well as anything else that includes_bar
or_baz
). This is off by default, and is turned on with:smart_partials => true
. It is opening and reading all the files in the source directory for every change, but anecdotally, it's much faster than doing a full-sweep recompile.foo.sass
andbar.css.sass
naming conventions.:compass => true
and it'll automatically require Compass and include it in the guard-sass load paths.Output now looks like:
I've been testing it with my team for a few days, and it seems to work great so far.