summaryrefslogtreecommitdiff
path: root/lib/chef/util/powershell/cmdlet_result.rb
diff options
context:
space:
mode:
authorJay Mundrawala <jdmundrawala@gmail.com>2015-03-10 14:13:58 -0700
committerJay Mundrawala <jdmundrawala@gmail.com>2015-03-20 14:38:01 -0700
commitbf1690709e532c10a534db544e264b0fd047a5f8 (patch)
treef639840c809ce003814951be532cb9a95de6c6dd /lib/chef/util/powershell/cmdlet_result.rb
parent3d6675cac2ac2463a7fa577d8d7a44bd18addd51 (diff)
downloadchef-bf1690709e532c10a534db544e264b0fd047a5f8.tar.gz
JSON needs to be kept separate from other output
Write-Host and friends can utlimately poplute stdout. This renders the json invalid
Diffstat (limited to 'lib/chef/util/powershell/cmdlet_result.rb')
-rw-r--r--lib/chef/util/powershell/cmdlet_result.rb11
1 files changed, 9 insertions, 2 deletions
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