Use helper module to silence warnings

This commit is contained in:
Chris Roberts 2017-05-08 17:03:38 -07:00
parent 7e49c6a609
commit 10cb43b917
2 changed files with 2 additions and 10 deletions

View File

@ -31,9 +31,7 @@ module Vagrant
def wsl?
if !defined?(@_wsl)
@_wsl = false
original_verbose = $VERBOSE
begin
$VERBOSE = nil
SilenceWarnings.silence! do
# Use PATH values to check for `/mnt/c` path indicative of WSL
if ENV.fetch("PATH", "").downcase.include?("/mnt/c")
# Validate WSL via uname output
@ -42,8 +40,6 @@ module Vagrant
@_wsl = true
end
end
ensure
$VERBOSE = original_verbose
end
end
@_wsl

View File

@ -29,17 +29,13 @@ module Vagrant
exts = ENV['PATHEXT'].split(';')
end
current_verbose = $VERBOSE
$VERBOSE = nil
begin
SilenceWarnings.silence! do
ENV['PATH'].encode('UTF-8', 'binary', invalid: :replace, undef: :replace, replace: '').split(File::PATH_SEPARATOR).each do |path|
exts.each do |ext|
exe = "#{path}#{File::SEPARATOR}#{cmd}#{ext}"
return exe if File.executable? exe
end
end
ensure
$VERBOSE = current_verbose
end
return nil