Skip to content

Commit

Permalink
(maint) quote file path in file_contents_on and file_exists_on
Browse files Browse the repository at this point in the history
  • Loading branch information
Ciprian Badescu committed May 18, 2020
1 parent 8532fbe commit 87dad4d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/beaker/dsl/helpers/host_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -492,12 +492,12 @@ def win_ads_path(file_path)
# @return [Boolean] Whether the file exists on the host (using `test -f`)
def file_exists_on(host, file_path)
if host['platform'] =~ /windows/
command = %(Test-Path #{file_path})
command = %(Test-Path "#{file_path}")

if file_path.include?(':')
split_path = win_ads_path(file_path)

command = %(Test-Path #{split_path[:path]})
command = %(Test-Path "#{split_path[:path]}")
command += %( -AND Get-Item -path #{split_path[:path]} -stream #{split_path[:ads]}) if split_path[:ads]
end

Expand Down Expand Up @@ -555,7 +555,7 @@ def file_contents_on(host, file_path)
if host['platform'] =~ /windows/
file_path.gsub!('/', '\\')

command = %{Get-Content -Raw -Path #{file_path}}
command = %{Get-Content -Raw -Path "#{file_path}"}
command += %{ -Stream #{split_path[:ads]}} if split_path[:ads]

file_contents = on(host, powershell(command))&.stdout&.strip
Expand Down

0 comments on commit 87dad4d

Please sign in to comment.