Skip to content
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

Preprocess in deploy/prune only #788

Merged
merged 1 commit into from Dec 29, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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