Class: Fastlane::Actions::RestoreFileAction

Inherits:
Fastlane::Action show all
Defined in:
fastlane/lib/fastlane/actions/restore_file.rb

Constant Summary

Constants inherited from Fastlane::Action

Fastlane::Action::AVAILABLE_CATEGORIES, Fastlane::Action::RETURN_TYPES

Class Method Summary collapse

Methods inherited from Fastlane::Action

action_name, authors, deprecated_notes, details, lane_context, method_missing, other_action, output, return_type, return_value, sample_return_value, shell_out_should_use_bundle_exec?, step_text

Class Method Details

.authorObject



21
22
23
# File 'fastlane/lib/fastlane/actions/restore_file.rb', line 21

def self.author
  "gin0606"
end

.available_optionsObject



25
26
27
28
29
30
31
# File 'fastlane/lib/fastlane/actions/restore_file.rb', line 25

def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :path,
                                 description: "Original file name you want to restore",
                                 optional: false)
  ]
end

.categoryObject



39
40
41
# File 'fastlane/lib/fastlane/actions/restore_file.rb', line 39

def self.category
  :misc
end

.descriptionObject



13
14
15
# File 'fastlane/lib/fastlane/actions/restore_file.rb', line 13

def self.description
  'This action restore your file that was backuped with the `backup_file` action'
end

.example_codeObject



33
34
35
36
37
# File 'fastlane/lib/fastlane/actions/restore_file.rb', line 33

def self.example_code
  [
    'restore_file(path: "/path/to/file")'
  ]
end

.is_supported?(platform) ⇒ Boolean

Returns:



17
18
19
# File 'fastlane/lib/fastlane/actions/restore_file.rb', line 17

def self.is_supported?(platform)
  true
end

.run(params) ⇒ Object



4
5
6
7
8
9
10
11
# File 'fastlane/lib/fastlane/actions/restore_file.rb', line 4

def self.run(params)
  path = params[:path]
  backup_path = "#{path}.back"
  UI.user_error!("Could not find file '#{backup_path}'") unless File.exist?(backup_path)
  FileUtils.cp(backup_path, path, { preserve: true })
  FileUtils.rm(backup_path)
  UI.message("Successfully restored backup 📤")
end