getConfig static method
Implementation
static Map<String, dynamic> getConfig(
{String? configFile, FCoreGenType? type}) {
// if `fcoregen.yaml` exists use it as config file, otherwise use `pubspec.yaml`
String filePath = 'fcoregen.yaml';
if (type != null && type == FCoreGenType.fastlane) {
filePath = 'fastlane.yaml';
} else {
if (configFile != null && File(configFile).existsSync()) {
filePath = configFile;
} else if (!File(filePath).existsSync()) {
filePath = 'pubspec.yaml';
}
}
final yamlMap = loadYaml(File(filePath).readAsStringSync()) as Map;
if (yamlMap['fcoregen'] is! Map) {
throw Exception('Your `$filePath` file does not contain a '
'`fcoregen` section.');
}
// yamlMap has the type YamlMap, which has several unwanted side effects
final config = <String, dynamic>{};
for (MapEntry<dynamic, dynamic> entry in yamlMap['fcoregen'].entries) {
if (entry.value is YamlList) {
var list = <String>[];
for (var value in (entry.value as YamlList)) {
if (value is String) {
list.add(value);
}
}
config[entry.key as String] = list;
} else {
config[entry.key as String] = entry.value;
}
}
return config;
}