From 82fd9ca8224d4c6ca295cbd1fbc00ad15cdc922c Mon Sep 17 00:00:00 2001 From: Mitchell Chambers Date: Thu, 18 Apr 2024 10:31:04 +1000 Subject: [PATCH] feat: attribute on_windows? method to rubyworks-facets rbconfig --- lib/pwsh/util.rb | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) 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.