Skip to content

Commit

Permalink
Pulls in missing methods from freshli-cli
Browse files Browse the repository at this point in the history
  • Loading branch information
mscottford committed Aug 30, 2023
1 parent 1dc1622 commit 318e144
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions lib/corgibytes/freshli/commons/execute.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,27 @@
# frozen_string_literal: true

require 'open3'
require 'mkmf'

module Corgibytes
module Freshli
module Commons
# Contains utility methods for executing commands and working with their output.
module Execute

def msbuild_dll_path
dotnet_exe_path = File.realpath(find_executable('dotnet'))
dotnet_dir = File.dirname(dotnet_exe_path)
sdk_dir = File.join(dotnet_dir, 'sdk', Dir.children(File.join(dotnet_dir, 'sdk')).max)
result = File.join(sdk_dir, 'MSBuild.dll')
result = result.gsub('/', '\\') if Gem.win_platform?
result
end

def null_output_target
Gem.win_platform? ? '\\\\.\\nul' : '/dev/null'
end

def enable_dotnet_command_colors
ENV['DOTNET_SYSTEM_CONSOLE_ALLOW_ANSI_COLOR_REDIRECTION'] = 'true'
end
Expand All @@ -31,7 +46,7 @@ def write_buffered_output_to_correct_stream(buffer, stream, stdout, stderr)
end
end

BUFFER_LEN = 128
BUFFER_LEN = 8

def fill_buffer_from_stream(stream, buffer)
# loop through reading data until there is an EOF (value is nil)
Expand Down Expand Up @@ -89,10 +104,6 @@ def execute(command)
end
exit_status
end

def null_output_target
Gem.win_platform? ? 'NUL:' : '/dev/null'
end
end
end
end
Expand Down

0 comments on commit 318e144

Please sign in to comment.