Skip to content

Commit b53fec9

Browse files
bryanoltmanfelangel
authored andcommitted
fix: throw exception if flavor not found in shorebird.yaml (#63)
* fix: throw exception if flavor not found in shorebird.yaml * fix test
1 parent 83e1f56 commit b53fec9

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

packages/flutter_tools/gradle/src/main/groovy/flutter.groovy

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1404,7 +1404,11 @@ class FlutterPlugin implements Plugin<Project> {
14041404

14051405
// Update the app_id to the correct flavor if one was provided.
14061406
if (variant.flavorName != null && !variant.flavorName.isEmpty()) {
1407-
shorebirdYamlData['app_id'] = shorebirdYamlData.flavors[variant.flavorName]
1407+
def shorebirdFlavor = shorebirdYamlData.flavors[variant.flavorName]
1408+
if (shorebirdFlavor == null) {
1409+
throw new GradleException("Flavor '${variant.flavorName}' not found in shorebird.yaml")
1410+
}
1411+
shorebirdYamlData['app_id'] = shorebirdFlavor
14081412
}
14091413

14101414
// Remove any flavors. This is a no-op if the flavors key doesn't exist.

packages/flutter_tools/test/general.shard/shorebird/shorebird_yaml_test.dart

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,16 @@ base_url: https://example.com
8585
final Directory tempDir = Directory.systemTemp.createTempSync('shorebird_yaml_test.');
8686
final File tempFile = File('${tempDir.path}/shorebird.yaml');
8787
tempFile.writeAsStringSync(yamlContents);
88-
updateShorebirdYaml(const BuildInfo(BuildMode.release, 'foo', treeShakeIcons: false), tempFile.path, environment: <String, String>{'SHOREBIRD_PUBLIC_KEY': '4-a'});
88+
updateShorebirdYaml(
89+
const BuildInfo(
90+
BuildMode.release,
91+
'foo',
92+
treeShakeIcons: false,
93+
packageConfigPath: '',
94+
),
95+
tempFile.path,
96+
environment: <String, String>{'SHOREBIRD_PUBLIC_KEY': '4-a'},
97+
);
8998
final String updatedContents = tempFile.readAsStringSync();
9099
// Order is not guaranteed, so parse as YAML to compare.
91100
final YamlDocument updated = loadYamlDocument(updatedContents);

0 commit comments

Comments
 (0)