Minor tweak to #1695

This commit is contained in:
Thomas Reynolds 2015-11-27 14:16:55 -08:00
parent b0582bcebf
commit 4594f46fb8
8 changed files with 20 additions and 33 deletions

View file

@ -398,7 +398,6 @@ module Middleman
execute_callbacks(:before_shutdown) execute_callbacks(:before_shutdown)
end end
# Set attributes (global variables) # Set attributes (global variables)
# #
# @deprecated Prefer accessing settings through "config". # @deprecated Prefer accessing settings through "config".

View file

@ -37,7 +37,8 @@ module Middleman
engine = extension[1..-1].to_sym engine = extension[1..-1].to_sym
# Store last engine for later (could be inside nested renders) # Store last engine for later (could be inside nested renders)
context.current_engine, engine_was = engine, context.current_engine context.current_engine = engine
engine_was = context.current_engine
# Save current buffer for later # Save current buffer for later
buf_was = context.save_buffer buf_was = context.save_buffer

View file

@ -21,7 +21,7 @@ module Middleman
).to_bind_addresses ).to_bind_addresses
@port = server_information.port @port = server_information.port
@server_name = server_information.server_name.dup unless server_information.server_name == nil @server_name = server_information.server_name.dup unless server_information.server_name.nil?
@site_addresses = ServerUrl.new( @site_addresses = ServerUrl.new(
hosts: server_information.site_addresses, hosts: server_information.site_addresses,

View file

@ -133,9 +133,7 @@ module Middleman
locs[:current_path] ||= destination_path locs[:current_path] ||= destination_path
# Certain output file types don't use layouts # Certain output file types don't use layouts
unless opts.key?(:layout) opts[:layout] = false unless opts.key?(:layout) || !ext != '.html'
opts[:layout] = false if ext != '.html'
end
renderer = ::Middleman::TemplateRenderer.new(@app, file_descriptor[:full_path].to_s) renderer = ::Middleman::TemplateRenderer.new(@app, file_descriptor[:full_path].to_s)
renderer.render(locs, opts) renderer.render(locs, opts)

View file

@ -182,14 +182,8 @@ module Middleman
# @return [void] # @return [void]
Contract Any Contract Any
def poll_once! def poll_once!
removed = @files.keys updated = ::Middleman::Util.all_files_under(@directory.to_s)
removed = @files.keys.reject { |p| updated.include?(p) }
updated = []
::Middleman::Util.all_files_under(@directory.to_s).each do |filepath|
removed.delete(filepath)
updated << filepath
end
update(updated, removed) update(updated, removed)
@ -314,16 +308,10 @@ module Middleman
# @return [Array] All related file paths, not including the source file paths. # @return [Array] All related file paths, not including the source file paths.
Contract ArrayOf[String] => ArrayOf[String] Contract ArrayOf[String] => ArrayOf[String]
def find_related_files(files) def find_related_files(files)
files.map do |file| files.flat_map do |file|
related_files = [] # If any partial file changes, reload all non-partials
Dir[File.join(@directory, app.config[:source], "**/[^_]*.#{File.extname(file)}")] if File.basename(file).start_with?('_')
# If any SASS file changes, reload all non-partials end.compact.uniq - files
if file =~ /\.(sass|scss)$/
related_files |= Dir[File.join(@directory, app.config[:css_dir], '**/[^_]*.{scss,sass}')]
end
related_files
end.flatten.uniq - files
end end
end end
end end

View file

@ -42,7 +42,8 @@ module Middleman
# @api private # @api private
# @return [String] The old buffer. # @return [String] The old buffer.
def save_buffer def save_buffer
@_out_buf, buf_was = '', @_out_buf buf_was = @_out_buf
@_out_buf = ''
buf_was buf_was
end end