Permalink
Browse files

Merge pull request #472 from jugglinmike/fail-check-for-empty-output

Fail checks when output directory is not present
  • Loading branch information...
ddfreyne committed Sep 6, 2014
2 parents 7a3db8a + 10b4481 commit a442c7a70d771b87041c8ed19410eb7157455190
Showing with 21 additions and 1 deletion.
  1. +11 −1 lib/nanoc/extra/checking/check.rb
  2. +10 −0 test/extra/checking/test_check.rb
@@ -2,6 +2,12 @@
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
@@ -25,7 +31,11 @@ def add_issue(desc, params = {})
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
@@ -11,4 +11,14 @@ def test_output_filenames
end
end
def test_no_output_dir
with_site do |site|
site.config[:output_dir] = 'non-existent'
check = Nanoc::Extra::Checking::Check.new(site)
assert_raises Nanoc::Extra::Checking::OutputDirNotFoundError do
check.output_filenames
end
end
end
end

0 comments on commit a442c7a

Please sign in to comment.