diff --git a/middleman-core/fixtures/asset-host-app/source/javascripts/asset_host.js b/middleman-core/fixtures/asset-host-app/source/javascripts/asset_host.js new file mode 100644 index 00000000..251ce693 --- /dev/null +++ b/middleman-core/fixtures/asset-host-app/source/javascripts/asset_host.js @@ -0,0 +1,2 @@ +var a = jQuery.css("h1", "font-size"); +console.log(a); diff --git a/middleman-core/lib/middleman-core/sources/source_watcher.rb b/middleman-core/lib/middleman-core/sources/source_watcher.rb index e1a3fdd4..cb163abd 100644 --- a/middleman-core/lib/middleman-core/sources/source_watcher.rb +++ b/middleman-core/lib/middleman-core/sources/source_watcher.rb @@ -49,6 +49,8 @@ module Middleman # Reference to lower level listener attr_reader :listener + IGNORED_DIRECTORIES = %w(.git node_modules .sass-cache) + # Construct a new SourceWatcher # # @param [Middleman::Sources] parent The parent collection. @@ -182,7 +184,7 @@ module Middleman Contract ArrayOf[Pathname] def find_new_files! - new_files = ::Middleman::Util.all_files_under(@directory.to_s) + new_files = ::Middleman::Util.all_files_under(@directory.to_s, &method(:should_not_recurse?)) .reject { |p| @files.key?(p) } update(new_files, []).flatten.map { |s| s[:full_path] } @@ -193,7 +195,7 @@ module Middleman # @return [void] Contract ArrayOf[Pathname] def poll_once! - updated = ::Middleman::Util.all_files_under(@directory.to_s) + updated = ::Middleman::Util.all_files_under(@directory.to_s, &method(:should_not_recurse?)) removed = @files.keys.reject { |p| updated.include?(p) } result = update(updated, removed) @@ -217,6 +219,11 @@ module Middleman protected + Contract Pathname => Bool + def should_not_recurse?(p) + IGNORED_DIRECTORIES.include?(p.basename.to_s) + end + # The `listen` gem callback. # # @param [Array] modified List of modified files. diff --git a/middleman-core/lib/middleman-core/util.rb b/middleman-core/lib/middleman-core/util.rb index cfbcb9ee..f0ca99cd 100644 --- a/middleman-core/lib/middleman-core/util.rb +++ b/middleman-core/lib/middleman-core/util.rb @@ -156,16 +156,14 @@ module Middleman def all_files_under(path, &ignore) path = Pathname(path) - if path.directory? + if ignore && ignore.call(path) + [] + elsif path.directory? path.children.flat_map do |child| all_files_under(child, &ignore) end.compact elsif path.file? - if block_given? && yield(path) - [] - else - [path] - end + [path] else [] end