New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fail checks when output directory is not present #472

Merged
merged 2 commits into from Sep 6, 2014
Jump to file or symbol
Failed to load files and symbols.
+21 −1
Diff settings

Always

Just for now

@@ -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
ProTip! Use n and p to navigate between commits in a pull request.