Skip to content

Commit

Permalink
fix: multiline string cmd for prepare_apk (#23)
Browse files Browse the repository at this point in the history
If running the bundletool fastlane plugin on Windows cmd, you get an
error - `The syntax of the command is incorrect.`. The reason is that
putting new lines in the ruby string creates new lines in the output,
and this can lead to inconsistent run in some shells.

When using `\` we ensure that the resulting command is a single line.

Co-authored-by: Vladyslav Androshchuk <[email protected]>
  • Loading branch information
1 parent 35bb3a3 commit ceb9fe1
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/fastlane/plugin/bundletool/actions/bundletool_action.rb
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,11 @@ def self.prepare_apk!(output_path, target_path)
puts_important("Creating path #{target_dir_name} since does not exist")
FileUtils.mkdir_p target_dir_name
end
cmd = "mv \"#{output_path}\" \"#{@bundletool_temp_path}/output.zip\" &&
unzip \"#{@bundletool_temp_path}/output.zip\" -d \"#{@bundletool_temp_path}\" &&
mv \"#{@bundletool_temp_path}/universal.apk\" \"#{target_path}\""

cmd = "mv \"#{output_path}\" \"#{@bundletool_temp_path}/output.zip\" &&"\
"unzip \"#{@bundletool_temp_path}/output.zip\" -d \"#{@bundletool_temp_path}\" &&"\
"mv \"#{@bundletool_temp_path}/universal.apk\" \"#{target_path}\""

Open3.popen3(cmd) do |_, _, stderr, wait_thr|
exit_status = wait_thr.value
raise stderr.read unless exit_status.success?
Expand Down

0 comments on commit ceb9fe1

Please sign in to comment.