Skip to content

Commit

Permalink
Merge pull request #2088 from DrBu7cher/master
Browse files Browse the repository at this point in the history
[patrol_cli] fix(analytics.dart): sanitize version check command in _getFlutterVersion()
  • Loading branch information
piotruela authored Feb 5, 2024
2 parents 83517b3 + 19be9e8 commit 66cc1c0
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
4 changes: 4 additions & 0 deletions packages/patrol_cli/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 2.6.3

- Fix invalid JSON output of version check command (#2087).

## 2.6.2

- Print link to devtools regardless of open-devtools flag (#2076).
Expand Down
10 changes: 9 additions & 1 deletion packages/patrol_cli/lib/src/analytics/analytics.dart
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,16 @@ FlutterVersion _getFlutterVersion() {
runInShell: true,
);

final versionData = jsonDecode(result.stdOut) as Map<String, dynamic>;
final versionData =
jsonDecode(cleanJsonResult(result)) as Map<String, dynamic>;
final frameworkVersion = versionData['frameworkVersion'] as String;
final channel = versionData['channel'] as String;
return FlutterVersion(frameworkVersion, channel);
}

// Workaround for https://github.com/flutter/flutter/issues/122814
String cleanJsonResult(io.ProcessResult result) {
final parts = result.stdOut.split('}')..removeLast();
final cleanedString = parts.join('}');
return '$cleanedString}';
}
2 changes: 1 addition & 1 deletion packages/patrol_cli/lib/src/base/constants.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
/// Version of Patrol CLI. Must be kept in sync with pubspec.yaml.
/// If you update this, make sure that compatibility-table.mdx is updated (if needed)
const version = '2.6.2';
const version = '2.6.3';
2 changes: 1 addition & 1 deletion packages/patrol_cli/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: patrol_cli
description: >
Command-line tool for Patrol, a powerful Flutter-native UI testing framework.
version: 2.6.2 # Must be kept in sync with constants.dart
version: 2.6.3 # Must be kept in sync with constants.dart
homepage: https://patrol.leancode.co
repository: https://github.com/leancodepl/patrol/tree/master/packages/patrol_cli
issue_tracker: https://github.com/leancodepl/patrol/issues?q=is%3Aopen+is%3Aissue+label%3A%22package%3A+patrol_cli%22
Expand Down

0 comments on commit 66cc1c0

Please sign in to comment.