Skip to content

Commit

Permalink
Merge pull request #949 from nanoc/gh-948-prune-w-non-existing-output…
Browse files Browse the repository at this point in the history
…-dir

Fix prune crash when output dir does not exist
  • Loading branch information
denisdefreyne committed Oct 2, 2016
2 parents fc48586 + bac07a8 commit b0dbe6c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/nanoc/extra/pruner.rb
Expand Up @@ -26,6 +26,8 @@ def initialize(site, dry_run: false, exclude: [])
def run
require 'find'

return unless File.directory?(site.config[:output_dir])

# Get compiled files
# FIXME: requires #build_reps to have been called
all_raw_paths = site.compiler.reps.flat_map { |r| r.raw_paths.values }
Expand Down
16 changes: 16 additions & 0 deletions spec/nanoc/regressions/gh_948_spec.rb
@@ -0,0 +1,16 @@
describe 'GH-948', site: true, stdio: true do
before do
File.write('content/foo.md', 'Foo!')

File.open('nanoc.yaml', 'w') do |io|
io << 'prune:' << "\n"
io << ' auto_prune: true' << "\n"
end

FileUtils.rm_rf('output')
end

it 'does not crash when output dir is not present' do
Nanoc::CLI.run(%w(compile))
end
end

0 comments on commit b0dbe6c

Please sign in to comment.