From c4434f27af5c84b38d5927840b949a8ea173089d Mon Sep 17 00:00:00 2001 From: Ivan Tse Date: Wed, 28 May 2014 01:16:34 -0400 Subject: [PATCH] Get relative paths of directories to ignore Use `Pathname#realpath` to get absolute paths so that `Pathname#relative_path_from` will not raise an exception. Also add the config files to this list. --- lib/jekyll/commands/build.rb | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/lib/jekyll/commands/build.rb b/lib/jekyll/commands/build.rb index 816c5b3f..cdf8cc63 100644 --- a/lib/jekyll/commands/build.rb +++ b/lib/jekyll/commands/build.rb @@ -58,13 +58,19 @@ module Jekyll source = options['source'] destination = options['destination'] + config_files = Configuration[options].config_files(options) + paths = config_files + Array(destination) + ignored = [] - begin - dest = Pathname.new(destination).relative_path_from(Pathname.new(source)).to_s - ignored = Regexp.new(Regexp.escape(dest)) - rescue ArgumentError - # Destination is outside the source, no need to ignore it. - ignored = nil + source_abs = Pathname.new(source).realpath + paths.each do |p| + path_abs = Pathname.new(p).realpath + begin + rel_path = path_abs.relative_path_from(source_abs).to_s + ignored << Regexp.new(Regexp.escape(rel_path)) unless rel_path.start_with?('../') + rescue ArgumentError + # Could not find a relative path + end end listener = Listen.to(