File tree 2 files changed +29
-8
lines changed
2 files changed +29
-8
lines changed Original file line number Diff line number Diff line change @@ -541,21 +541,19 @@ class WebPlugin extends PluginPlatform {
541
541
});
542
542
543
543
factory WebPlugin .fromYaml (String name, YamlMap yaml) {
544
- assert (validate (yaml));
544
+ if (yaml['pluginClass' ] is ! String ) {
545
+ throwToolExit ('The plugin `$name ` is missing the required field `pluginClass` in pubspec.yaml' );
546
+ }
547
+ if (yaml['fileName' ] is ! String ) {
548
+ throwToolExit ('The plugin `$name ` is missing the required field `fileName` in pubspec.yaml' );
549
+ }
545
550
return WebPlugin (
546
551
name: name,
547
552
pluginClass: yaml['pluginClass' ] as String ,
548
553
fileName: yaml['fileName' ] as String ,
549
554
);
550
555
}
551
556
552
- static bool validate (YamlMap yaml) {
553
- if (yaml == null ) {
554
- return false ;
555
- }
556
- return yaml['pluginClass' ] is String && yaml['fileName' ] is String ;
557
- }
558
-
559
557
static const String kConfigKey = 'web' ;
560
558
561
559
/// The name of the plugin.
Original file line number Diff line number Diff line change @@ -290,6 +290,29 @@ void main() {
290
290
]);
291
291
});
292
292
293
+ testWithoutContext ('Web plugin tool exits if fileName field missing' , () {
294
+ final FileSystem fileSystem = MemoryFileSystem .test ();
295
+ const String pluginYamlRaw =
296
+ 'platforms:\n '
297
+ ' web:\n '
298
+ ' pluginClass: WebSamplePlugin\n ' ;
299
+
300
+ final YamlMap pluginYaml = loadYaml (pluginYamlRaw) as YamlMap ;
301
+ expect (
302
+ () => Plugin .fromYaml (
303
+ _kTestPluginName,
304
+ _kTestPluginPath,
305
+ pluginYaml,
306
+ null ,
307
+ const < String > [],
308
+ fileSystem: fileSystem,
309
+ ),
310
+ throwsToolExit (
311
+ message: 'The plugin `$_kTestPluginName ` is missing the required field `fileName` in pubspec.yaml' ,
312
+ ),
313
+ );
314
+ });
315
+
293
316
testWithoutContext ('Windows assumes win32 when no variants are given' , () {
294
317
final FileSystem fileSystem = MemoryFileSystem .test ();
295
318
const String pluginYamlRaw =
You can’t perform that action at this time.
0 commit comments