Use helper module to silence warnings
This commit is contained in:
parent
7e49c6a609
commit
10cb43b917
|
@ -31,9 +31,7 @@ module Vagrant
|
||||||
def wsl?
|
def wsl?
|
||||||
if !defined?(@_wsl)
|
if !defined?(@_wsl)
|
||||||
@_wsl = false
|
@_wsl = false
|
||||||
original_verbose = $VERBOSE
|
SilenceWarnings.silence! do
|
||||||
begin
|
|
||||||
$VERBOSE = nil
|
|
||||||
# Use PATH values to check for `/mnt/c` path indicative of WSL
|
# Use PATH values to check for `/mnt/c` path indicative of WSL
|
||||||
if ENV.fetch("PATH", "").downcase.include?("/mnt/c")
|
if ENV.fetch("PATH", "").downcase.include?("/mnt/c")
|
||||||
# Validate WSL via uname output
|
# Validate WSL via uname output
|
||||||
|
@ -42,8 +40,6 @@ module Vagrant
|
||||||
@_wsl = true
|
@_wsl = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
ensure
|
|
||||||
$VERBOSE = original_verbose
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@_wsl
|
@_wsl
|
||||||
|
|
|
@ -29,17 +29,13 @@ module Vagrant
|
||||||
exts = ENV['PATHEXT'].split(';')
|
exts = ENV['PATHEXT'].split(';')
|
||||||
end
|
end
|
||||||
|
|
||||||
current_verbose = $VERBOSE
|
SilenceWarnings.silence! do
|
||||||
$VERBOSE = nil
|
|
||||||
begin
|
|
||||||
ENV['PATH'].encode('UTF-8', 'binary', invalid: :replace, undef: :replace, replace: '').split(File::PATH_SEPARATOR).each do |path|
|
ENV['PATH'].encode('UTF-8', 'binary', invalid: :replace, undef: :replace, replace: '').split(File::PATH_SEPARATOR).each do |path|
|
||||||
exts.each do |ext|
|
exts.each do |ext|
|
||||||
exe = "#{path}#{File::SEPARATOR}#{cmd}#{ext}"
|
exe = "#{path}#{File::SEPARATOR}#{cmd}#{ext}"
|
||||||
return exe if File.executable? exe
|
return exe if File.executable? exe
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
ensure
|
|
||||||
$VERBOSE = current_verbose
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|
Loading…
Reference in New Issue