Skip to content

Commit

Permalink
feat: attribute on_windows? method to rubyworks-facets rbconfig
Browse files Browse the repository at this point in the history
  • Loading branch information
chambersmp committed Apr 18, 2024
1 parent 56a4b81 commit 82fd9ca
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions lib/pwsh/util.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 82fd9ca

Please sign in to comment.