Method: Chef::Sugar::Shell#version_for
- Defined in:
- lib/chef/sugar/shell.rb
#version_for(cmd, flag = '--version') ⇒ String
The version for a given command. This method does NOT check if the command exists! It is assumed the command existence has been checked with which or similar. To simply check if an installed version is acceptable, please see installed_at_version.
Assumptions:
1. The command exists.
2. The command outputs version information to +$stdout+ or +$stderr+.
Did you know that java outputs its version to $stderr?
118 119 120 121 122 123 |
# File 'lib/chef/sugar/shell.rb', line 118 def version_for(cmd, flag = '--version') cmd = Mixlib::ShellOut.new("#{cmd} #{flag}") cmd.run_command cmd.error! [cmd.stdout.strip, cmd.stderr.strip].join("\n") end |