Skip to content

Commit

Permalink
Write status information to stderr
Browse files Browse the repository at this point in the history
  • Loading branch information
denisdefreyne committed Oct 22, 2016
1 parent 700e575 commit 76b3088
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
6 changes: 3 additions & 3 deletions lib/nanoc/cli/command_runner.rb
Expand Up @@ -45,8 +45,8 @@ def in_site_dir?
#
# @return [void]
def load_site(preprocess: false)
print 'Loading site… '
$stdout.flush
$stderr.print 'Loading site… '
$stderr.flush

if site.nil?
raise ::Nanoc::Int::Errors::GenericTrivial, 'The current working directory does not seem to be a Nanoc site.'
Expand All @@ -56,7 +56,7 @@ def load_site(preprocess: false)
site.compiler.action_provider.preprocess(site)
end

puts 'done'
$stderr.puts 'done'
end

# @return [Boolean] true if debug output is enabled, false if not
Expand Down
9 changes: 6 additions & 3 deletions spec/nanoc/cli/commands/show_rules_spec.rb
@@ -1,4 +1,4 @@
describe Nanoc::CLI::Commands::ShowRules do
describe Nanoc::CLI::Commands::ShowRules, stdio: true do
describe '#run' do
subject { runner.run }

Expand Down Expand Up @@ -73,7 +73,6 @@

let(:expected_out) do
<<-EOS
Loading site… done
\e[1m\e[33mItem /about.md\e[0m:
Rep default: /*.md
Rep text: /**/*
Expand All @@ -98,8 +97,12 @@
.gsub(/^ {8}/, '')
end

it 'outputs item and layout rules' do
it 'writes item and layout rules to stdout' do
expect { subject }.to output(expected_out).to_stdout
end

it 'writes status informaion to stderr' do
expect { subject }.to output("Loading site… done\n").to_stderr
end
end
end

0 comments on commit 76b3088

Please sign in to comment.