mirror of
https://github.com/jekyll/jekyll.git
synced 2026-02-18 02:21:30 -05:00
When an include cannot be found, only print file path relative to source.
This commit is contained in:
@@ -119,10 +119,14 @@ eos
|
||||
if safe && !realpath_prefixed_with?(path, dir)
|
||||
raise IOError.new "The included file '#{path}' should exist and should not be a symlink"
|
||||
elsif !File.exist?(path)
|
||||
raise IOError.new "Included file '#{path}' not found"
|
||||
raise IOError.new "Included file '#{path_relative_to_source(dir, path)}' not found"
|
||||
end
|
||||
end
|
||||
|
||||
def path_relative_to_source(dir, path)
|
||||
File.join(INCLUDES_DIR, path.sub(Regexp.new("^#{dir}"), ""))
|
||||
end
|
||||
|
||||
def realpath_prefixed_with?(path, dir)
|
||||
File.exist?(path) && File.realpath(path).start_with?(dir)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user