From 5385a18dda9c9395475fbdf04184b43878bb2cc7 Mon Sep 17 00:00:00 2001 From: Long Kimhak Date: Tue, 26 Jul 2022 08:50:03 +0700 Subject: [PATCH] improve config validation --- lib/cli_commands.dart | 1 - lib/utils/utils.dart | 20 ++++++++++++-------- pubspec.yaml | 3 ++- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/lib/cli_commands.dart b/lib/cli_commands.dart index 71dd551..f39d880 100644 --- a/lib/cli_commands.dart +++ b/lib/cli_commands.dart @@ -89,7 +89,6 @@ void _checkConfig(Map config) { final List errors = []; final globalImagePath = _checkImageExists(config: config, parameter: 'image_path'); - final platforms = config['platforms'] as Map; // ANDROID diff --git a/lib/utils/utils.dart b/lib/utils/utils.dart index daac021..5682436 100644 --- a/lib/utils/utils.dart +++ b/lib/utils/utils.dart @@ -1,14 +1,18 @@ /// Checks if the config file contains a `platform` bool hasPlatformConfig(Map config) { final bool isHasPlatforms = config.containsKey('platforms'); - final platforms = config['platforms'] as Map; - final bool isHasPlatformSpecific = isNeedingNewAndroidIcon(platforms) || - isNeedingNewIosIcon(platforms) || - isNeedingNewMacOSIcon(platforms) || - isNeedingNewWindowsIcon(platforms) || - isNeedingNewWebIcon(platforms) || - isNeedingNewLinuxIcon(platforms); - return isHasPlatforms && isHasPlatformSpecific; + if (isHasPlatforms) { + final platforms = config['platforms'] as Map; + final bool isHasPlatformSpecific = isNeedingNewAndroidIcon(platforms) || + isNeedingNewIosIcon(platforms) || + isNeedingNewMacOSIcon(platforms) || + isNeedingNewWindowsIcon(platforms) || + isNeedingNewWebIcon(platforms) || + isNeedingNewLinuxIcon(platforms); + + return isHasPlatformSpecific; + } + return false; } /// Checks if the config has android. diff --git a/pubspec.yaml b/pubspec.yaml index 455758d..a5c09db 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -17,5 +17,6 @@ environment: dev_dependencies: build_runner: ^2.2.0 - build_version: ^2.1.1 # dart run build_runner build --delete-conflicting-outputs + # dart run build_runner build --delete-conflicting-outputs + build_version: ^2.1.1 test: ^1.21.4