Skip to content

Commit

Permalink
Merge pull request #788 from nanoc/double-preprocess
Browse files Browse the repository at this point in the history
Preprocess in deploy/prune only
  • Loading branch information
denisdefreyne committed Dec 29, 2015
2 parents 1a21f5a + 9a95b15 commit c72c424
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 1 deletion.
1 change: 0 additions & 1 deletion lib/nanoc/cli/command_runner.rb
Expand Up @@ -22,7 +22,6 @@ def site
@site ||= nil
if self.is_in_site_dir? && @site.nil?
@site = Nanoc::Int::SiteLoader.new.new_from_cwd
@site.compiler.action_provider.preprocess(@site)
end

@site
Expand Down
2 changes: 2 additions & 0 deletions lib/nanoc/cli/commands/deploy.rb
Expand Up @@ -14,6 +14,8 @@ module Nanoc::CLI::Commands
class Deploy < ::Nanoc::CLI::CommandRunner
def run
load_site
# FIXME: ugly to preprocess here
site.compiler.action_provider.preprocess(site)

# List deployers
if options[:'list-deployers']
Expand Down
2 changes: 2 additions & 0 deletions lib/nanoc/cli/commands/prune.rb
Expand Up @@ -16,6 +16,8 @@ module Nanoc::CLI::Commands
class Prune < ::Nanoc::CLI::CommandRunner
def run
load_site
# FIXME: ugly to preprocess here
site.compiler.action_provider.preprocess(site)
site.compiler.build_reps

if options.key?(:yes)
Expand Down
19 changes: 19 additions & 0 deletions spec/nanoc/regressions/gh_787_spec.rb
@@ -0,0 +1,19 @@
describe 'GH-787', site: true, stdio: true do
before do
File.write('Rules', <<EOS)
preprocess do
@items.create('foo', {}, '/pig.md')
end
compile '/**/*' do
write '/oink.html'
end
layout '/foo.*', :erb
EOS
end

it 'runs the preprocessor only once' do
expect { Nanoc::CLI.run(['compile']) }.not_to raise_error
end
end
15 changes: 15 additions & 0 deletions spec/spec_helper.rb
Expand Up @@ -27,6 +27,21 @@ def self.setup_cleaning_streams
end
end

c.around(:each, stdio: true) do |example|
orig_stdout = $stdout
orig_stderr = $stderr

unless ENV['QUIET'] == 'false'
$stdout = StringIO.new
$stderr = StringIO.new
end

example.run

$stdout = orig_stdout
$stderr = orig_stderr
end

c.before(:each, site: true) do
FileUtils.mkdir_p('content')
FileUtils.mkdir_p('layouts')
Expand Down

0 comments on commit c72c424

Please sign in to comment.