class Fastlane::Actions::UnzipAction

Public Class Methods

authors() click to toggle source
# File lib/fastlane/plugin/unzip/actions/unzip_action.rb, line 70
def self.authors
  ["maxoly"]
end
available_options() click to toggle source
# File lib/fastlane/plugin/unzip/actions/unzip_action.rb, line 48
def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :file,
                                 env_name: "FL_UNZIP_FILE",
                                 description: "The path of the ZIP archive",
                                 verify_block: proc do |value|
                                   UI.user_error!("Couldn't find file at path '#{File.expand_path(value)}'") unless File.exist?(value)
                                 end),
    FastlaneCore::ConfigItem.new(key: :destination_path,
                                 env_name: "FL_UNZIP_DESTINATION_PATH",
                                 description: "An optional directory to which to extract files",
                                 optional: true),
    FastlaneCore::ConfigItem.new(key: :password,
                                 env_name: "FL_UNZIP_PASSWORD",
                                 description: "The password to decrypt encrypted zipfile",
                                 optional: true)
  ]
end
description() click to toggle source

@!group Documentation

# File lib/fastlane/plugin/unzip/actions/unzip_action.rb, line 37
def self.description
  "Extract compressed files in a ZIP"
end
details() click to toggle source
# File lib/fastlane/plugin/unzip/actions/unzip_action.rb, line 41
def self.details
  [
    "unzip will extract files from a ZIP archive.",
    "The default behavior is to extract into the current directory all files from the specified ZIP archive."
  ].join("\n")
end
is_supported?(platform) click to toggle source
# File lib/fastlane/plugin/unzip/actions/unzip_action.rb, line 74
def self.is_supported?(platform)
  true
end
return_value() click to toggle source
# File lib/fastlane/plugin/unzip/actions/unzip_action.rb, line 67
def self.return_value
end
run(params) click to toggle source
# File lib/fastlane/plugin/unzip/actions/unzip_action.rb, line 4
def self.run(params)
  require 'shellwords'

  begin
    escaped_file = params[:file].shellescape
    UI.important "🎁  Unzipping file #{escaped_file}..."

    # Base command
    command = "unzip -o #{escaped_file}"

    # Destination
    if params[:destination_path]
      escaped_destination = params[:destination_path].shellescape
      command << " -d #{escaped_destination}"
    end

    # Password
    if params[:password]
      escaped_password = params[:password].shellescape
      command << " -P #{escaped_password}"
    end

    Fastlane::Actions.sh(command, log: false)
    UI.success "Unzip finished ✅"
  rescue => ex
    UI.user_error!("Error unzipping file: #{ex}")
  end
end