Class: Fastlane::Helper::YarnHelper
- Inherits:
-
Object
- Object
- Fastlane::Helper::YarnHelper
- Defined in:
- lib/fastlane/plugin/yarn/helper/yarn_helper.rb
Instance Attribute Summary collapse
-
#commands ⇒ Object
Returns the value of attribute commands.
-
#flags ⇒ Object
class methods that you define here become available in your action as ‘Helper::YarnHelper.your_method`.
-
#options ⇒ Object
Returns the value of attribute options.
-
#package_path ⇒ Object
Returns the value of attribute package_path.
-
#yarn ⇒ Object
Returns the value of attribute yarn.
Instance Method Summary collapse
- #check_install ⇒ Object
- #check_package ⇒ Object
-
#initialize(package_path: nil) ⇒ YarnHelper
constructor
A new instance of YarnHelper.
- #install_dependencies ⇒ Object
-
#trigger(command: nil, flags: nil, options: nil, print_command: true, print_command_output: true) ⇒ Object
Run a certain action.
Constructor Details
#initialize(package_path: nil) ⇒ YarnHelper
Returns a new instance of YarnHelper.
13 14 15 16 17 18 19 20 21 |
# File 'lib/fastlane/plugin/yarn/helper/yarn_helper.rb', line 13 def initialize(package_path: nil) self.package_path = package_path if self.package_path self.yarn = "cd #{File.dirname(self.package_path)} && yarn" else self.yarn = "yarn" end end |
Instance Attribute Details
#commands ⇒ Object
Returns the value of attribute commands.
8 9 10 |
# File 'lib/fastlane/plugin/yarn/helper/yarn_helper.rb', line 8 def commands @commands end |
#flags ⇒ Object
class methods that you define here become available in your action as ‘Helper::YarnHelper.your_method`
7 8 9 |
# File 'lib/fastlane/plugin/yarn/helper/yarn_helper.rb', line 7 def flags @flags end |
#options ⇒ Object
Returns the value of attribute options.
9 10 11 |
# File 'lib/fastlane/plugin/yarn/helper/yarn_helper.rb', line 9 def @options end |
#package_path ⇒ Object
Returns the value of attribute package_path.
10 11 12 |
# File 'lib/fastlane/plugin/yarn/helper/yarn_helper.rb', line 10 def package_path @package_path end |
#yarn ⇒ Object
Returns the value of attribute yarn.
11 12 13 |
# File 'lib/fastlane/plugin/yarn/helper/yarn_helper.rb', line 11 def yarn @yarn end |
Instance Method Details
#check_install ⇒ Object
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/fastlane/plugin/yarn/helper/yarn_helper.rb', line 29 def check_install check_package begin command = [self.yarn, "--version"].compact.join(" ") Action.sh(command, print_command: false, print_command_output: false) rescue Errno::ENOENT => e UI.error("Yarn not installed, please install with Homebrew or npm.") raise e end end |
#check_package ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/fastlane/plugin/yarn/helper/yarn_helper.rb', line 45 def check_package if self.package_path.nil? package_path = 'package.json' else package_path = self.package_path end unless File.exist?(package_path) UI.error("Could not find package.json") raise Errno::ENOENT end end |
#install_dependencies ⇒ Object
40 41 42 43 |
# File 'lib/fastlane/plugin/yarn/helper/yarn_helper.rb', line 40 def install_dependencies UI.("Installing dependencies") trigger(command: "install") end |
#trigger(command: nil, flags: nil, options: nil, print_command: true, print_command_output: true) ⇒ Object
Run a certain action
24 25 26 27 |
# File 'lib/fastlane/plugin/yarn/helper/yarn_helper.rb', line 24 def trigger(command: nil, flags: nil, options: nil, print_command: true, print_command_output: true) command = [self.yarn, command, flags, ].compact.join(" ") Action.sh(command, print_command: print_command, print_command_output: print_command_output) end |