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.
This commit is contained in:
Ivan Tse 2014-05-28 01:16:34 -04:00
parent 6ba077cf37
commit c4434f27af
1 changed files with 12 additions and 6 deletions

View File

@ -58,13 +58,19 @@ module Jekyll
source = options['source'] source = options['source']
destination = options['destination'] destination = options['destination']
config_files = Configuration[options].config_files(options)
paths = config_files + Array(destination)
ignored = []
begin source_abs = Pathname.new(source).realpath
dest = Pathname.new(destination).relative_path_from(Pathname.new(source)).to_s paths.each do |p|
ignored = Regexp.new(Regexp.escape(dest)) path_abs = Pathname.new(p).realpath
rescue ArgumentError begin
# Destination is outside the source, no need to ignore it. rel_path = path_abs.relative_path_from(source_abs).to_s
ignored = nil ignored << Regexp.new(Regexp.escape(rel_path)) unless rel_path.start_with?('../')
rescue ArgumentError
# Could not find a relative path
end
end end
listener = Listen.to( listener = Listen.to(