File tree Expand file tree Collapse file tree 9 files changed +17
-26
lines changed Expand file tree Collapse file tree 9 files changed +17
-26
lines changed Original file line number Diff line number Diff line change @@ -24,6 +24,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
2424- Referring to an undefined platform no longer causes a crash; it's now a helpful error message
2525- A copy/paste error that prevented compiler warning flags from being supplied has been fixed, via jgfoster
2626- RSpec was not communicating compile errors from unit test executables that failed to build. Now it does, via jgfoster
27+ - Windows paths now avoid picking up backslashes, for proper equality comparisons
2728
2829### Security
2930
Original file line number Diff line number Diff line change @@ -90,7 +90,9 @@ def config_dump
9090
9191 # @return [String] the path to the Arduino libraries directory
9292 def lib_dir
93- Pathname . new ( config_dump [ "directories" ] [ "user" ] ) + "libraries"
93+ user_dir_raw = config_dump [ "directories" ] [ "user" ]
94+ user_dir = OS . windows? ? Host . windows_to_pathname ( user_dir_raw ) : user_dir_raw
95+ Pathname . new ( user_dir ) + "libraries"
9496 end
9597
9698 # Board manager URLs
Original file line number Diff line number Diff line change @@ -43,7 +43,7 @@ def self.autolocated_executable
4343 # The executable Arduino file in an existing installation, or nil
4444 # @return [Pathname]
4545 def self . existing_executable
46- self . must_implement ( __method__ )
46+ Host . which ( "arduino-cli" )
4747 end
4848
4949 # The local file (dir) name of the desired IDE package (zip/tar/etc)
Original file line number Diff line number Diff line change @@ -17,12 +17,6 @@ def self.extracted_file
1717 "arduino-cli"
1818 end
1919
20- # The executable Arduino file in an existing installation, or nil
21- # @return [string]
22- def self . existing_executable
23- Host . which ( "arduino-cli" )
24- end
25-
2620 # Make any preparations or run any checks prior to making changes
2721 # @return [string] Error message, or nil if success
2822 def prepare
Original file line number Diff line number Diff line change @@ -17,12 +17,6 @@ def self.extracted_file
1717 "arduino-cli"
1818 end
1919
20- # The executable Arduino file in an existing installation, or nil
21- # @return [string]
22- def self . existing_executable
23- Host . which ( "arduino-cli" )
24- end
25-
2620 # Make any preparations or run any checks prior to making changes
2721 # @return [string] Error message, or nil if success
2822 def prepare
Original file line number Diff line number Diff line change @@ -28,12 +28,6 @@ def package_file
2828 "arduino-cli_#{ @desired_version } _Windows_64bit.zip"
2929 end
3030
31- # The executable Arduino file in an existing installation, or nil
32- # @return [string]
33- def self . existing_executable
34- Host . which ( "arduino-cli" )
35- end
36-
3731 # The technology that will be used to extract the download
3832 # (for logging purposes)
3933 # @return [string]
@@ -57,5 +51,11 @@ def self.extracted_file
5751 "arduino-cli.exe"
5852 end
5953
54+ # The executable Arduino file in a forced installation, or nil
55+ # @return [Pathname]
56+ def self . force_installed_executable
57+ Pathname . new ( Host . windows_to_pathname ( ENV [ 'HOME' ] ) ) + self . extracted_file
58+ end
59+
6060 end
6161end
Original file line number Diff line number Diff line change @@ -17,13 +17,14 @@ class Host
1717 # via https://stackoverflow.com/a/5471032/2063546
1818 # which('ruby') #=> /usr/bin/ruby
1919 # @param cmd [String] the command to search for
20- # @return [String ] the full path to the command if it exists
20+ # @return [Pathname ] the full path to the command if it exists
2121 def self . which ( cmd )
2222 exts = ENV [ 'PATHEXT' ] ? ENV [ 'PATHEXT' ] . split ( ';' ) : [ '' ]
23- ENV [ 'PATH' ] . split ( File ::PATH_SEPARATOR ) . each do |path |
23+ ENV [ 'PATH' ] . split ( File ::PATH_SEPARATOR ) . each do |string_path |
24+ path = OS . windows? ? windows_to_pathname ( string_path ) : Pathname . new ( string_path )
2425 exts . each do |ext |
25- exe = File . join ( path , "#{ cmd } #{ ext } " )
26- return exe if File . executable? ( exe ) && !File . directory? ( exe )
26+ exe = path . join ( "#{ cmd } #{ ext } " )
27+ return exe if exe . executable? && !exe . directory?
2728 end
2829 end
2930 nil
Original file line number Diff line number Diff line change 77 it "has correct class properties" do
88 ad = ArduinoCI ::ArduinoDownloader
99
10- expect { ad . existing_executable } . to raise_error ( NotImplementedError )
1110 expect { ad . extracted_file } . to raise_error ( NotImplementedError )
1211 expect { ad . extracter } . to raise_error ( NotImplementedError )
1312 expect { ad . extract ( "foo" ) } . to raise_error ( NotImplementedError )
Original file line number Diff line number Diff line change @@ -54,7 +54,7 @@ def with_tmpdir(path)
5454 it "can find things with which" do
5555 ruby_path = ArduinoCI ::Host . which ( "ruby" )
5656 expect ( ruby_path ) . not_to be nil
57- expect ( ruby_path . include? "ruby" ) . to be true
57+ expect ( ruby_path . to_s . include? "ruby" ) . to be true
5858 end
5959 end
6060
You can’t perform that action at this time.
0 commit comments