6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/fastlane/plugin/flutter_version/helper/flutter_version_helper.rb', line 6
def self.read_version_from_pubspec
pubspec_path = 'pubspec.yaml'
unless File.exist?(pubspec_path)
UI.user_error!("Could not find pubspec.yaml in current directory")
return nil
end
begin
pubspec = YAML.load_file(pubspec_path)
version_name = pubspec['version']&.split('+')&.first
build_number = pubspec['version']&.split('+')&.last
if version_name.nil? || build_number.nil?
UI.user_error!("Could not find version information in pubspec.yaml")
return nil
end
Fastlane::FlutterVersion::VersionInfo.new(version_name, build_number)
rescue => e
UI.error("Error reading pubspec.yaml: #{e.message}")
return nil
end
end
|