Skip to content

Removed use of powershell #47

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 6, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions arduino_ci.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Gem::Specification.new do |spec|
spec.require_paths = ["lib"]

spec.add_dependency "os", "~> 1.0"
spec.add_dependency "rubyzip", "~> 1.2.1"

spec.add_development_dependency "bundler", "~> 1.15"
spec.add_development_dependency "rspec", "~> 3.0"
Expand Down
23 changes: 10 additions & 13 deletions lib/arduino_ci/arduino_downloader_windows.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,14 @@
require 'win32/registry'
require "arduino_ci/arduino_downloader"
require 'open-uri'
require 'zip'
require "fileutils"

module ArduinoCI

# Manage the POSIX download & install of Arduino
class ArduinoDownloaderWindows < ArduinoDownloader

def powershell(*args)
encoded_cmd = Base64.strict_encode64(args.shelljoin.encode('utf-16le'))
system("powershell.exe", "-NoProfile", "-encodedCommand", encoded_cmd)
end

def cygwin(*args)
system("%CYG_ROOT%/bin/bash", "-lc", args.shelljoin)
end

# Make any preparations or run any checks prior to making changes
# @return [string] Error message, or nil if success
def prepare
Expand Down Expand Up @@ -45,9 +38,9 @@ def download
# @return [bool] whether successful
def install
# Move only the content of the directory
powershell("Move-Item", extracted_file + "\*", self.class.force_install_location)
FileUtils.mv extracted_file, self.class.force_install_location
# clean up the no longer required root extracted folder
powershell("Remove-Item", extracted_file)
FileUtils.rm_rf extracted_file
end

# The local filename of the desired IDE package (zip/tar/etc)
Expand All @@ -66,9 +59,13 @@ def extracter
# Extract the package_file to extracted_file
# @return [bool] whether successful
def extract
powershell("Expand-Archive", "-Path", package_file, "-DestinationPath", extracted_file)
Zip::File.open(package_file) do |zip|
zip.each do |file|
file.extract(file.name)
end
end
# clean up the no longer required zip
powershell("Remove-Item", package_file)
FileUtils.rm_rf package_file
end

# The local file (dir) name of the extracted IDE package (zip/tar/etc)
Expand Down