Skip to content

Commit

Permalink
fix parenthesis in file and dir exists calls
Browse files Browse the repository at this point in the history
  • Loading branch information
trevor-vaughan committed Feb 10, 2020
1 parent be17b78 commit f6d7160
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions lib/beaker/dsl/helpers/host_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -470,12 +470,12 @@ def backup_the_file host, current_dir, new_dir, filename = 'puppet.conf'
# @return [Boolean] Whether the file exists on the host (using `test -f`)
def file_exists_on(host, file_path)
if host['platform'] =~ /windows/
command = Command.new(%{IF exist "#{file_path}" exit 0 ELSE exit 1}, [], { :cmdexe => true, :accept_all_exit_codes => true })
command = Command.new(%{IF exist "#{file_path}" ( exit 0 ) ELSE ( exit 1 )}, [], { :cmdexe => true })
else
command = Command.new(%(test -f "#{file_path}"), [], accept_all_exit_codes: true)
command = Command.new(%(test -f "#{file_path}"), [])
end

return on(host, command).exit_code.zero?
return on(host, command, { :accept_all_exit_codes => true}).exit_code.zero?
end

# Check whether a directory exists on the host
Expand All @@ -488,12 +488,12 @@ def directory_exists_on(host, dir_path)
if host['platform'] =~ /windows/
dir_path = "#{dir_path}\\" unless (dir_path[-1].chr == '\\')

command = Command.new(%{IF exist "#{dir_path}" exit 0 ELSE exit 1}, [], { :cmdexe => true, :accept_all_exit_codes => true })
command = Command.new(%{IF exist "#{dir_path}" ( exit 0 ) ELSE ( exit 1 )}, [], { :cmdexe => true })
else
command = Command.new(%(test -d "#{dir_path}"), [], accept_all_exit_codes: true)
command = Command.new(%(test -d "#{dir_path}"), [])
end

return on(host, command).exit_code.zero?
return on(host, command, { :accept_all_exit_codes => true }).exit_code.zero?
end

# Check whether a symlink exists on the host
Expand Down

0 comments on commit f6d7160

Please sign in to comment.