Skip to content

Commit 44c5af7

Browse files
authored
Option to skip download if file is already present (#56)
1 parent 0b887f3 commit 44c5af7

File tree

1 file changed

+26
-3
lines changed

1 file changed

+26
-3
lines changed

lib/commands/build/distribution/install.rb

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
require 'zip'
44
require 'rbconfig'
55
require 'tmpdir'
6+
require 'tty-prompt'
67

78
module EmergeCLI
89
module Commands
@@ -49,10 +50,32 @@ def call(**options)
4950
app_id = response['appId']
5051

5152
extension = platform == 'ios' ? 'ipa' : 'apk'
52-
Logger.info 'Downloading build...'
5353
output_name = @options[:output] || "#{@options[:build_id]}.#{extension}"
54-
`curl --progress-bar -L '#{download_url}' -o #{output_name} `
55-
Logger.info "✅ Build downloaded to #{output_name}"
54+
55+
if File.exist?(output_name)
56+
Logger.info "Build file already exists at #{output_name}"
57+
prompt = TTY::Prompt.new
58+
choice = prompt.select('What would you like to do?', {
59+
'Install existing file' => :install,
60+
'Overwrite with new download' => :overwrite,
61+
'Cancel' => :cancel
62+
})
63+
64+
case choice
65+
when :install
66+
Logger.info 'Proceeding with existing file...'
67+
when :overwrite
68+
Logger.info 'Downloading new build...'
69+
`curl --progress-bar -L '#{download_url}' -o #{output_name}`
70+
Logger.info "✅ Build downloaded to #{output_name}"
71+
when :cancel
72+
raise 'Operation cancelled by user'
73+
end
74+
else
75+
Logger.info 'Downloading build...'
76+
`curl --progress-bar -L '#{download_url}' -o #{output_name}`
77+
Logger.info "✅ Build downloaded to #{output_name}"
78+
end
5679
rescue StandardError => e
5780
Logger.error "❌ Failed to download build: #{e.message}"
5881
raise e

0 commit comments

Comments
 (0)