0

A build system that I use at work invokes several external console applications, Node.js among others.

The issue I am seeing is the STDOUT channel seems to not work after Open3.capture3 is invoked. For instance, I have a task called compileLess:

desc "Compile LESS"
task :compileLess do
   puts "Preparing to compile LESS..."
   execute "recess less/bootstrap.less --compress > output/css/bootstrap.min.css"
   puts "Finished compiling LESS"
end


def execute(cmdLine, print_stdout = false)
   puts "Executing #{cmdLine}"
   stdout, stderr, status = Open3.capture3(cmdLine)
   puts stdout if print_stdout
   return stdout, stderr, status
end

What I would expect to see is something like:

Preparing to compile LESS...
Executing recess less/bootstrap.less --compress > output/css/bootstrap.min.css
Finished compiling LESS

But anything after the invocation of Open3.capture3 disables puts and print. I can force them to work by explicitly using:

STDOUT.puts "goodbye world"

I just want to know why it doesn't work.

Specs:

  • Window 7 Professional 32 bit
  • Ruby 1.9.3p392 (2013-02-22) [i386-mingw32]
  • Rake, version 10.1.0
  • Node v0.10.22
the Tin Man
  • 158,662
  • 42
  • 215
  • 303
MattSaw
  • 451
  • 2
  • 11

1 Answers1

1

You redirected the STDOUT of the command-line with > output/css/bootstrap.min.css.

Your STDOUT from capture3() is empty of course.

the Tin Man
  • 158,662
  • 42
  • 215
  • 303
jaeheung
  • 1,208
  • 6
  • 7
  • Any suggestion as to how I can write the css to disk without losing STDOUT? – MattSaw Nov 14 '13 at 10:45
  • 1
    @MattSaw How about " | tee output/css/bootstrap.min.css" instead of " > output/css/bootstrap.min.css"? Not sure if it's what you wanted. – jaeheung Nov 14 '13 at 19:11