Skip to content

Commit 299593b

Browse files
committed
Move to Chef::Mixin::ShellOut
`Chef::Mixin::Command` was deprecated in Chef 11.
1 parent ef361ea commit 299593b

File tree

1 file changed

+9
-22
lines changed

1 file changed

+9
-22
lines changed

providers/execute.rb

+9-22
Original file line numberDiff line numberDiff line change
@@ -20,28 +20,15 @@
2020
# limitations under the License.
2121
#
2222

23-
#pruned Chef::Provider::Execute + optional `block' param
24-
25-
include Chef::Mixin::Command
23+
require 'chef/mixin/shell_out'
24+
include Chef::Mixin::ShellOut
2625

2726
def action_run
28-
args = {
29-
:command => @new_resource.command,
30-
:command_string => @new_resource.to_s,
31-
}
32-
args[:only_if] = @new_resource.only_if if @new_resource.only_if
33-
args[:not_if] = @new_resource.not_if if @new_resource.not_if
34-
args[:timeout] = @new_resource.timeout if @new_resource.timeout
35-
args[:cwd] = @new_resource.cwd if @new_resource.cwd
36-
37-
status, stdout, stderr = output_of_command(args[:command], args)
38-
if status.exitstatus == 0
39-
@new_resource.block.call(stdout) if @new_resource.block
40-
@new_resource.updated_by_last_action(true)
41-
Chef::Log.info("Ran #{@new_resource} successfully")
42-
else
43-
command_output = "JENKINS STDOUT: #{stdout}"
44-
command_output << "JENKINS STDERR: #{stderr}"
45-
handle_command_failures(status, command_output, args)
46-
end
27+
args = {}
28+
args[:timeout] = new_resource.timeout if new_resource.timeout
29+
args[:cwd] = new_resource.cwd if new_resource.cwd
30+
cmd = shell_out!(new_resource.command, args)
31+
new_resource.block.call(cmd.stdout) if new_resource.block
32+
new_resource.updated_by_last_action(true)
33+
Chef::Log.info("Ran #{new_resource} successfully")
4734
end

0 commit comments

Comments
 (0)