From bf1690709e532c10a534db544e264b0fd047a5f8 Mon Sep 17 00:00:00 2001 From: Jay Mundrawala Date: Tue, 10 Mar 2015 14:13:58 -0700 Subject: JSON needs to be kept separate from other output Write-Host and friends can utlimately poplute stdout. This renders the json invalid --- lib/chef/util/powershell/cmdlet_result.rb | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'lib/chef/util/powershell/cmdlet_result.rb') diff --git a/lib/chef/util/powershell/cmdlet_result.rb b/lib/chef/util/powershell/cmdlet_result.rb index 246701a7bc..31d8d38ccc 100644 --- a/lib/chef/util/powershell/cmdlet_result.rb +++ b/lib/chef/util/powershell/cmdlet_result.rb @@ -22,18 +22,25 @@ class Chef::Util::Powershell class CmdletResult attr_reader :output_format - def initialize(status, output_format) + def initialize(status, streams, output_format) @status = status @output_format = output_format + @streams = streams end def stderr @status.stderr end + def stream(name) + @streams[name].read + end + def return_value if output_format == :object - Chef::JSONCompat.parse(@status.stdout) + Chef::JSONCompat.parse(stream(:json)) + elsif output_format == :json + stream(:json) else @status.stdout end -- cgit v1.2.1