Class: Fastlane::Helper::FlutterHelper
- Inherits:
-
Object
- Object
- Fastlane::Helper::FlutterHelper
- Defined in:
- lib/fastlane/plugin/flutter/helper/flutter_helper.rb
Class Method Summary collapse
- .dev_dependency?(package) ⇒ Boolean
- .execute(*command) ⇒ Object
- .flutter(*argv, &block) ⇒ Object
- .flutter_sdk_root ⇒ Object
- .git(*argv, &block) ⇒ Object
Class Method Details
.dev_dependency?(package) ⇒ Boolean
27 28 29 |
# File 'lib/fastlane/plugin/flutter/helper/flutter_helper.rb', line 27 def self.dev_dependency?(package) (YAML.load_file('pubspec.yaml')['dev_dependencies'] || {}).key?(package) end |
.execute(*command) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/fastlane/plugin/flutter/helper/flutter_helper.rb', line 31 def self.execute(*command) # TODO(dotdoom): make CommandExecutor (and Actions.sh) behave similarly. command = command.shelljoin UI.command(command) Open3.popen3(command) do |stdin, stdout, stderr, wait_thread| errors_thread = Thread.new { stderr.read } stdin.close if block_given? output = stdout.read ignore_error = yield(wait_thread.value, output, errors_thread) else stdout.each_line do |stdout_line| UI.command_output(stdout_line.chomp) end end unless wait_thread.value.success? || (ignore_error == true) UI.shell_error!(<<-ERROR) The following command has failed: $ #{command} [#{wait_thread.value}] #{errors_thread.value} ERROR end end end |
.flutter(*argv, &block) ⇒ Object
7 8 9 |
# File 'lib/fastlane/plugin/flutter/helper/flutter_helper.rb', line 7 def self.flutter(*argv, &block) execute(File.join(flutter_sdk_root, 'bin', 'flutter'), *argv, &block) end |
.flutter_sdk_root ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/fastlane/plugin/flutter/helper/flutter_helper.rb', line 15 def self.flutter_sdk_root @flutter_sdk_root ||= File.( if ENV.include?('FLUTTER_SDK_ROOT') ENV['FLUTTER_SDK_ROOT'] elsif flutter_binary = FastlaneCore::CommandExecutor.which('flutter') File.dirname(File.dirname(flutter_binary)) else 'vendor/flutter' end ) end |
.git(*argv, &block) ⇒ Object
11 12 13 |
# File 'lib/fastlane/plugin/flutter/helper/flutter_helper.rb', line 11 def self.git(*argv, &block) execute('git', *argv, &block) end |