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:
parent
6ba077cf37
commit
c4434f27af
|
@ -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 = []
|
||||||
|
|
||||||
|
source_abs = Pathname.new(source).realpath
|
||||||
|
paths.each do |p|
|
||||||
|
path_abs = Pathname.new(p).realpath
|
||||||
begin
|
begin
|
||||||
dest = Pathname.new(destination).relative_path_from(Pathname.new(source)).to_s
|
rel_path = path_abs.relative_path_from(source_abs).to_s
|
||||||
ignored = Regexp.new(Regexp.escape(dest))
|
ignored << Regexp.new(Regexp.escape(rel_path)) unless rel_path.start_with?('../')
|
||||||
rescue ArgumentError
|
rescue ArgumentError
|
||||||
# Destination is outside the source, no need to ignore it.
|
# Could not find a relative path
|
||||||
ignored = nil
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
listener = Listen.to(
|
listener = Listen.to(
|
||||||
|
|
Loading…
Reference in New Issue