diff --git a/.travis.yml b/.travis.yml index 72b2e475..b8f54ad0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,6 +9,7 @@ rvm: - jruby-head - jruby - jruby-19mode + - 2.1.1 - 2.1.0 - 2.0.0 - 1.9.3 @@ -21,4 +22,4 @@ matrix: - rvm: jruby-head - rvm: jruby - rvm: jruby-19mode - - rvm: rbx-2 \ No newline at end of file + - rvm: rbx-2 diff --git a/middleman-core/lib/middleman-core/core_extensions/file_watcher.rb b/middleman-core/lib/middleman-core/core_extensions/file_watcher.rb index 1b499b5e..c5575a9c 100644 --- a/middleman-core/lib/middleman-core/core_extensions/file_watcher.rb +++ b/middleman-core/lib/middleman-core/core_extensions/file_watcher.rb @@ -4,13 +4,13 @@ module Middleman module FileWatcher IGNORE_LIST = [ - /^bin\//, - /^\.bundle\//, - /^vendor\//, - /^\.sass-cache\//, - /^\.cache\//, - /^\.git\//, + /^bin(\/|$)/, + /^\.bundle(\/|$)/, + /^vendor(\/|$)/, /^node_modules(\/|$)/, + /^\.sass-cache(\/|$)/, + /^\.cache(\/|$)/, + /^\.git(\/|$)/, /^\.gitignore$/, /\.DS_Store/, /^\.rbenv-.*$/, @@ -39,7 +39,7 @@ module Middleman end app.after_configuration do - config[:file_watcher_ignore] << %r{^#{config[:build_dir]}\/} + config[:file_watcher_ignore] << %r{^#{config[:build_dir]}(\/|$)} end # After config, load everything else @@ -99,7 +99,6 @@ module Middleman # @return [void] def did_change(path) path = Pathname(path) - return if ignored?(path) logger.debug "== File Change: #{path}" @known_paths << path self.run_callbacks(path, :changed) @@ -111,7 +110,6 @@ module Middleman # @return [void] def did_delete(path) path = Pathname(path) - return if ignored?(path) logger.debug "== File Deletion: #{path}" @known_paths.delete(path) self.run_callbacks(path, :deleted) @@ -131,7 +129,7 @@ module Middleman glob = (path + '**').to_s subset = @known_paths.select { |p| p.fnmatch(glob) } - ::Middleman::Util.all_files_under(path).each do |filepath| + ::Middleman::Util.all_files_under(path, &method(:ignored?)).each do |filepath| next if only_new && subset.include?(filepath) subset.delete(filepath) @@ -156,7 +154,6 @@ module Middleman @known_paths.include?(p) end - protected # Whether this path is ignored # @param [Pathname] path # @return [Boolean] @@ -165,6 +162,8 @@ module Middleman app.config[:file_watcher_ignore].any? { |r| path =~ r } end + protected + # Notify callbacks for a file given an array of callbacks # # @param [Pathname] path The file that was changed diff --git a/middleman-core/lib/middleman-core/extensions/asset_hash.rb b/middleman-core/lib/middleman-core/extensions/asset_hash.rb index 0934dbaa..058b5efd 100644 --- a/middleman-core/lib/middleman-core/extensions/asset_hash.rb +++ b/middleman-core/lib/middleman-core/extensions/asset_hash.rb @@ -41,6 +41,7 @@ class Middleman::Extensions::AssetHash < ::Middleman::Extension def manipulate_single_resource(resource) return unless options.exts.include?(resource.ext) return if ignored_resource?(resource) + return if resource.ignored? # Render through the Rack interface so middleware and mounted apps get a shot response = @rack_client.get(URI.escape(resource.destination_path), { 'bypass_asset_hash' => 'true' }) diff --git a/middleman-core/lib/middleman-core/preview_server.rb b/middleman-core/lib/middleman-core/preview_server.rb index d3f38bfa..209b223e 100644 --- a/middleman-core/lib/middleman-core/preview_server.rb +++ b/middleman-core/lib/middleman-core/preview_server.rb @@ -133,10 +133,12 @@ module Middleman @webrick.stop else added_and_modified.each do |path| + next if app.files.ignored?(path) app.files.did_change(path) end removed.each do |path| + next if app.files.ignored?(path) app.files.did_delete(path) end end diff --git a/middleman-core/lib/middleman-core/util.rb b/middleman-core/lib/middleman-core/util.rb index 71ce83f4..1bddf938 100644 --- a/middleman-core/lib/middleman-core/util.rb +++ b/middleman-core/lib/middleman-core/util.rb @@ -28,7 +28,7 @@ module Middleman return false if Tilt.registered?(ext.sub('.', '')) dot_ext = (ext.to_s[0] == ?.) ? ext.dup : ".#{ext}" - + if mime = ::Rack::Mime.mime_type(dot_ext, nil) !nonbinary_mime?(mime) else @@ -113,21 +113,27 @@ module Middleman end end - # Get a recursive list of files inside a set of paths. + # Get a recusive list of files inside a path. # Works with symlinks. # - # @param paths Some paths string or Pathname - # @return [Array] An array of filenames - def all_files_under(*paths) - paths.flat_map do |p| - path = Pathname(p) + # @param path Some path string or Pathname + # @param ignore A proc/block that returns true if a given path should be ignored - if a path + # is ignored, nothing below it will be searched either. + # @return [Array] An array of Pathnames for each file (no directories) + def all_files_under(path, &ignore) + path = Pathname(path) - if path.directory? - all_files_under(*path.children) - elsif path.file? - path - end - end.compact + return [] if ignore && ignore.call(path) + + if path.directory? + path.children.flat_map do |child| + all_files_under(child, &ignore) + end.compact + elsif path.file? + [path] + else + [] + end end # Given a source path (referenced either absolutely or relatively) @@ -248,7 +254,7 @@ module Middleman s.each_byte do |c| return true if binary_bytes.include?(c) end - + false end @@ -277,7 +283,7 @@ module Middleman end end end - + # A hash with indifferent access and magic predicates. # Copied from Thor # diff --git a/middleman-templates/lib/middleman-templates/shared/Gemfile.tt b/middleman-templates/lib/middleman-templates/shared/Gemfile.tt index 5bc18919..ec8e0fc9 100644 --- a/middleman-templates/lib/middleman-templates/shared/Gemfile.tt +++ b/middleman-templates/lib/middleman-templates/shared/Gemfile.tt @@ -8,4 +8,7 @@ gem "middleman", "~><%= Middleman::VERSION %>" gem "middleman-livereload", "~> 3.1.0" # For faster file watcher updates on Windows: -gem "wdm", "~> 0.1.0", :platforms => [:mswin, :mingw] \ No newline at end of file +gem "wdm", "~> 0.1.0", :platforms => [:mswin, :mingw] + +# Windows does not come with time zone data +gem "tzinfo-data", platforms: [:mswin, :mingw]