Skip to content

Commit

Permalink
chore(shorebird_cli): improve error message when Flutter project does…
Browse files Browse the repository at this point in the history
… not support macOS
  • Loading branch information
felangel committed Jan 16, 2025
1 parent a5c9edf commit 22fcbca
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,13 @@ class MacosNetworkEntitlementValidator extends Validator {
String get description => 'macOS app has Outgoing Connections entitlement';

@override
bool canRunInCurrentContext() =>
_macosDirectory != null && _macosDirectory!.existsSync();
bool canRunInCurrentContext() => _macosDirectory?.existsSync() ?? false;

@override
String? get incorrectContextMessage => '''
The ${_macosDirectory?.path ?? 'macos'} directory does not exist.
The command you are running must be run within a Flutter app project that supports the macOS platform.''';

@override
Future<List<ValidationIssue>> validate() async {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ void main() {
runWithOverrides(() => validator.canRunInCurrentContext()),
isTrue,
);
expect(
runWithOverrides(() => validator.incorrectContextMessage),
isNull,
);
});
});

Expand All @@ -100,6 +104,12 @@ void main() {
runWithOverrides(() => validator.canRunInCurrentContext()),
isFalse,
);
expect(
runWithOverrides(() => validator.incorrectContextMessage),
contains(
'''The command you are running must be run within a Flutter app project that supports the macOS platform.''',
),
);
});
});
});
Expand Down

0 comments on commit 22fcbca

Please sign in to comment.