diff --git a/lib/pwsh/util.rb b/lib/pwsh/util.rb index 4d795c21..ae2c5f32 100644 --- a/lib/pwsh/util.rb +++ b/lib/pwsh/util.rb @@ -7,14 +7,12 @@ module Util module_function # Verifies whether or not the current context is running on a Windows node. + # Implementation copied from `facets`: https://github.com/rubyworks/facets/blob/main/lib/standard/facets/rbconfig.rb # # @return [Bool] true if on windows def on_windows? - # Ruby only sets File::ALT_SEPARATOR on Windows and the Ruby standard - # library uses that to test what platform it's on. - require 'rbconfig' - is_windows = (RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/) - !!is_windows + host_os = RbConfig::CONFIG['host_os'] + !!(host_os =~ /mswin|mingw/) end # Verify paths specified are valid directories which exist.