lib/bolt/shell/powershell.rb in bolt-2.19.0 vs lib/bolt/shell/powershell.rb in bolt-2.20.0

- old
+ new

@@ -83,11 +83,11 @@ def write_executable(dir, file, filename = nil) filename ||= File.basename(file) validate_extensions(File.extname(filename)) destination = "#{dir}\\#{filename}" - conn.copy_file(file, destination) + conn.upload_file(file, destination) destination end def execute_process(path, arguments, stdin = nil) quoted_args = arguments.map { |arg| quote_string(arg) }.join(' ') @@ -162,14 +162,20 @@ Snippets.try_catch(task_path) end end def upload(source, destination, _options = {}) - conn.copy_file(source, destination) + conn.upload_file(source, destination) Bolt::Result.for_upload(target, source, destination) end + def download(source, destination, _options = {}) + download = File.join(destination, Bolt::Util.windows_basename(source)) + conn.download_file(source, destination, download) + Bolt::Result.for_download(target, source, destination, download) + end + def run_command(command, options = {}) command = [*env_declarations(options[:env_vars]), command].join("\r\n") if options[:env_vars] output = execute(command) Bolt::Result.for_command(target, @@ -218,11 +224,11 @@ # TODO: optimize upload of directories arguments['_installdir'] = dir task_dir = File.join(dir, task.tasks_dir) mkdirs([task_dir] + extra_files.map { |file| File.join(dir, File.dirname(file['name'])) }) extra_files.each do |file| - conn.copy_file(file['path'], File.join(dir, file['name'])) + conn.upload_file(file['path'], File.join(dir, file['name'])) end end task_path = write_executable(task_dir, executable) @@ -260,10 +266,10 @@ def execute(command) if conn.max_command_length && command.length > conn.max_command_length return with_tmpdir do |dir| command += "\r\nif (!$?) { if($LASTEXITCODE) { exit $LASTEXITCODE } else { exit 1 } }" script_file = File.join(dir, "#{SecureRandom.uuid}_wrapper.ps1") - conn.copy_file(StringIO.new(command), script_file) + conn.upload_file(StringIO.new(command), script_file) args = escape_arguments([script_file]) script_invocation = ['powershell.exe', *PS_ARGS, '-File', *args].join(' ') execute(script_invocation) end end