Class: Fastlane::Actions::NpmInstallAction

Inherits:
Action
  • Object
show all
Defined in:
lib/fastlane/plugin/npm/actions/npm_install_action.rb

Class Method Summary collapse

Class Method Details

.authorsObject



32
33
34
# File 'lib/fastlane/plugin/npm/actions/npm_install_action.rb', line 32

def self.authors
  ["Erick Martins"]
end

.available_optionsObject



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/fastlane/plugin/npm/actions/npm_install_action.rb', line 45

def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :step_name,
                       default_value: "Installing dependencies",
                         description: "Name for this step",
                            optional: true,
                                type: String),

    FastlaneCore::ConfigItem.new(key: :fresh,
                       default_value: false,
                         description: "Deletes node_modules folder",
                            optional: true,
                                type: Boolean),

    FastlaneCore::ConfigItem.new(key: :arguments,
                        default_value: [],
                          description: "Script arguments",
                            optional: true,
                                type: Array),
  ]
end

.descriptionObject



28
29
30
# File 'lib/fastlane/plugin/npm/actions/npm_install_action.rb', line 28

def self.description
  "A very simple plugin to run npm scripts"
end

.detailsObject



40
41
42
43
# File 'lib/fastlane/plugin/npm/actions/npm_install_action.rb', line 40

def self.details
  # Optional:
  "A very simple plugin to run npm scripts"
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


67
68
69
70
71
72
73
# File 'lib/fastlane/plugin/npm/actions/npm_install_action.rb', line 67

def self.is_supported?(platform)
  # Adjust this if your plugin only works for a particular platform (iOS vs. Android, for example)
  # See: https://docs.fastlane.tools/advanced/#control-configuration-by-lane-and-by-platform
  #
  # [:ios, :mac, :android].include?(platform)
  true
end

.return_valueObject



36
37
38
# File 'lib/fastlane/plugin/npm/actions/npm_install_action.rb', line 36

def self.return_value
  # If your method provides a return value, you can describe here what it does
end

.run(params) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/fastlane/plugin/npm/actions/npm_install_action.rb', line 7

def self.run(params)
  # rm may exit with non zero in the case where there is no node_modules and that's what we want anyway
  if params[:fresh]
    UI.important('Deleting node modules and installing packages')
    
    root_dir = Helper::NpmHelper.find_root_dir
    node_module_dir = File.join(root_dir, 'node_modules')

    FastlaneCore::CommandExecutor.execute(command: "rm -rf \"#{node_module_dir}\" 2> /dev/null",
                                    print_command: FastlaneCore::Globals.verbose?,
                                        print_all: FastlaneCore::Globals.verbose?)
  end
  

  other_action.npm_run(
    script: 'install', 
    step_name: params[:step_name],
    arguments: params[:arguments]
  )
end