Land #7178, Add a method to check the Powershell version

bug/bundler_fix
Pearce Barry 2016-08-11 11:02:41 -05:00
commit 6386d9daca
No known key found for this signature in database
GPG Key ID: 0916F4DEA5C5DE0A
1 changed files with 25 additions and 0 deletions

View File

@ -30,6 +30,31 @@ module Powershell
return false
end
#
# Returns the Powershell version
#
def get_powershell_version
return nil unless have_powershell?
process, pid, c = execute_script('$PSVersionTable.PSVersion')
o = ''
while (d = process.channel.read)
if d == ""
if (Time.now.to_i - start < time_out) && (o == '')
sleep 0.1
else
break
end
else
o << d
end
end
o.scan(/[\d \-]+/).last.split[0,2] * '.'
end
#
# Get/compare list of current PS processes - nested execution can spawn many children
# doing checks before and after execution allows us to kill more children...