lib/nanoc/extra/checking/check.rb in nanoc-3.7.3 vs lib/nanoc/extra/checking/check.rb in nanoc-3.7.4

- old
+ new

@@ -1,9 +1,15 @@ # encoding: utf-8 module Nanoc::Extra::Checking + class OutputDirNotFoundError < Nanoc::Errors::Generic + def initialize(directory_path) + super("Unable to run check against output directory at “#{directory_path}”: directory does not exist.") + end + end + class Check extend Nanoc::PluginRegistry::PluginMethods attr_reader :site @@ -23,10 +29,14 @@ @issues << Issue.new(desc, subject, self.class) end def output_filenames - Dir[@site.config[:output_dir] + '/**/*'].select { |f| File.file?(f) } + output_dir = @site.config[:output_dir] + unless File.exist?(output_dir) + raise Nanoc::Extra::Checking::OutputDirNotFoundError.new(output_dir) + end + Dir[output_dir + '/**/*'].select { |f| File.file?(f) } end end end