fastlane/lib/fastlane/lane.rb in fastlane-2.216.0 vs fastlane/lib/fastlane/lane.rb in fastlane-2.217.0
- old
+ new
@@ -22,14 +22,22 @@
self.class.verify_lane_name(name)
self.platform = platform
self.name = name
self.description = description
- self.block = block
+ # We want to support _both_ lanes expecting a `Hash` (like `lane :foo do |options|`), and lanes expecting
+ # keyword parameters (like `lane :foo do |param1:, param2:, param3: 'default value'|`)
+ block_expects_keywords = !block.nil? && block.parameters.any? { |type, _| [:key, :keyreq].include?(type) }
+ # Conversion of the `Hash` parameters (passed by `Lane#call`) into keywords has to be explicit in Ruby 3
+ # https://www.ruby-lang.org/en/news/2019/12/12/separation-of-positional-and-keyword-arguments-in-ruby-3-0/
+ self.block = block_expects_keywords ? proc { |options| block.call(**options) } : block
self.is_private = is_private
end
# Execute this lane
+ #
+ # @param [Hash] parameters The Hash of parameters to pass to the lane
+ #
def call(parameters)
block.call(parameters || {})
end
# @return [String] The lane + name of the lane. If there is no platform, it will only be the lane name