I can’t test whether a directory exists from within a Fastlane action nor lane. None of the following work for save_path = "./dir_name"
nor save_path = "dir_name"
in the current directory (from which fastlane
is being run):
!Dir.empty?(save_path)
!Dir[save_path].empty?
Dir.exist?(save_path)
File.exist?(save_path)
File.directory?(save_path)
I even tried to expand the relative path:
File.exists? File.expand_path(save_path)
I have referred to the following:
- Check if directory is empty in Ruby
- How to check if a given directory exists in Ruby
- https://blog.bigbinary.com/2017/02/28/dir-emtpy-included-in-ruby-2-4.html
- https://ruby-doc.org/core-2.2.0/Dir.html
How does one test to see if a directory exists from within Fastlane? Thank you for reading and for your help!
LOL Well, I discovered my issue. I didn't realize that I had to include the entire path to each of these statements, since I'm using
Dir.foreach
to iterate over part of the filesystem; the updated syntax is:This is versus
File.directory?("#{dir}")
in that if statement. I thought that the RubyDir
andFileUtil
libraries would look relative to the current directory for the remainder of the path.