Can't test if directory already exists from within Fastlane with Ruby
up vote
0
down vote
favorite
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!
fastlane fileutils ruby-2.5
add a comment |
up vote
0
down vote
favorite
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!
fastlane fileutils ruby-2.5
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
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!
fastlane fileutils ruby-2.5
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!
fastlane fileutils ruby-2.5
fastlane fileutils ruby-2.5
asked Nov 9 at 3:25
Wanda B.
417
417
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
up vote
0
down vote
The correct format to check this:
Dir.exist? "#{save_path}"
Will return true if it exists or false if not.
Thanks for your reply! Isn't this syntax equivalent toDir.exist?(save_path), as specified above? I appreciate your insight!
– Wanda B.
Nov 9 at 17:42
Yes, you're right, I didn't see that you write it also that way. Glad you found the solution anyway!
– rcarba
Nov 12 at 8:20
add a comment |
up vote
0
down vote
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:
Dir.foreach(save_path) do |dir|
next if dir == '.' or dir == '..'
if (File.directory?("#{save_path}#{dir}"))
begin
FileUtils.mkdir_p("./#{save_path}#{dir}/images")
rescue StandardError => e
UI.message("Failed to make directory ./#{save_path}#{dir}/images: #{e.to_s}")
return
end
end
end
This is versus File.directory?("#{dir}") in that if statement. I thought that the Ruby Dir and FileUtil libraries would look relative to the current directory for the remainder of the path.
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
The correct format to check this:
Dir.exist? "#{save_path}"
Will return true if it exists or false if not.
Thanks for your reply! Isn't this syntax equivalent toDir.exist?(save_path), as specified above? I appreciate your insight!
– Wanda B.
Nov 9 at 17:42
Yes, you're right, I didn't see that you write it also that way. Glad you found the solution anyway!
– rcarba
Nov 12 at 8:20
add a comment |
up vote
0
down vote
The correct format to check this:
Dir.exist? "#{save_path}"
Will return true if it exists or false if not.
Thanks for your reply! Isn't this syntax equivalent toDir.exist?(save_path), as specified above? I appreciate your insight!
– Wanda B.
Nov 9 at 17:42
Yes, you're right, I didn't see that you write it also that way. Glad you found the solution anyway!
– rcarba
Nov 12 at 8:20
add a comment |
up vote
0
down vote
up vote
0
down vote
The correct format to check this:
Dir.exist? "#{save_path}"
Will return true if it exists or false if not.
The correct format to check this:
Dir.exist? "#{save_path}"
Will return true if it exists or false if not.
answered Nov 9 at 12:50
rcarba
716
716
Thanks for your reply! Isn't this syntax equivalent toDir.exist?(save_path), as specified above? I appreciate your insight!
– Wanda B.
Nov 9 at 17:42
Yes, you're right, I didn't see that you write it also that way. Glad you found the solution anyway!
– rcarba
Nov 12 at 8:20
add a comment |
Thanks for your reply! Isn't this syntax equivalent toDir.exist?(save_path), as specified above? I appreciate your insight!
– Wanda B.
Nov 9 at 17:42
Yes, you're right, I didn't see that you write it also that way. Glad you found the solution anyway!
– rcarba
Nov 12 at 8:20
Thanks for your reply! Isn't this syntax equivalent to
Dir.exist?(save_path), as specified above? I appreciate your insight!– Wanda B.
Nov 9 at 17:42
Thanks for your reply! Isn't this syntax equivalent to
Dir.exist?(save_path), as specified above? I appreciate your insight!– Wanda B.
Nov 9 at 17:42
Yes, you're right, I didn't see that you write it also that way. Glad you found the solution anyway!
– rcarba
Nov 12 at 8:20
Yes, you're right, I didn't see that you write it also that way. Glad you found the solution anyway!
– rcarba
Nov 12 at 8:20
add a comment |
up vote
0
down vote
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:
Dir.foreach(save_path) do |dir|
next if dir == '.' or dir == '..'
if (File.directory?("#{save_path}#{dir}"))
begin
FileUtils.mkdir_p("./#{save_path}#{dir}/images")
rescue StandardError => e
UI.message("Failed to make directory ./#{save_path}#{dir}/images: #{e.to_s}")
return
end
end
end
This is versus File.directory?("#{dir}") in that if statement. I thought that the Ruby Dir and FileUtil libraries would look relative to the current directory for the remainder of the path.
add a comment |
up vote
0
down vote
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:
Dir.foreach(save_path) do |dir|
next if dir == '.' or dir == '..'
if (File.directory?("#{save_path}#{dir}"))
begin
FileUtils.mkdir_p("./#{save_path}#{dir}/images")
rescue StandardError => e
UI.message("Failed to make directory ./#{save_path}#{dir}/images: #{e.to_s}")
return
end
end
end
This is versus File.directory?("#{dir}") in that if statement. I thought that the Ruby Dir and FileUtil libraries would look relative to the current directory for the remainder of the path.
add a comment |
up vote
0
down vote
up vote
0
down vote
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:
Dir.foreach(save_path) do |dir|
next if dir == '.' or dir == '..'
if (File.directory?("#{save_path}#{dir}"))
begin
FileUtils.mkdir_p("./#{save_path}#{dir}/images")
rescue StandardError => e
UI.message("Failed to make directory ./#{save_path}#{dir}/images: #{e.to_s}")
return
end
end
end
This is versus File.directory?("#{dir}") in that if statement. I thought that the Ruby Dir and FileUtil libraries would look relative to the current directory for the remainder of the path.
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:
Dir.foreach(save_path) do |dir|
next if dir == '.' or dir == '..'
if (File.directory?("#{save_path}#{dir}"))
begin
FileUtils.mkdir_p("./#{save_path}#{dir}/images")
rescue StandardError => e
UI.message("Failed to make directory ./#{save_path}#{dir}/images: #{e.to_s}")
return
end
end
end
This is versus File.directory?("#{dir}") in that if statement. I thought that the Ruby Dir and FileUtil libraries would look relative to the current directory for the remainder of the path.
answered Nov 9 at 20:00
Wanda B.
417
417
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53219419%2fcant-test-if-directory-already-exists-from-within-fastlane-with-ruby%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown