mirror of
https://github.com/flutter/packages.git
synced 2025-08-14 18:12:30 +08:00
[flutter_plugin_tools] Use -version with java (#4171)
This commit is contained in:
@ -244,9 +244,12 @@ class FormatCommand extends PluginCommand {
|
||||
|
||||
/// Returns true if [command] can be run successfully.
|
||||
Future<bool> _hasDependency(String command) async {
|
||||
// Some versions of Java accept both -version and --version, but some only
|
||||
// accept -version.
|
||||
final String versionFlag = command == 'java' ? '-version' : '--version';
|
||||
try {
|
||||
final io.ProcessResult result =
|
||||
await processRunner.run(command, <String>['--version']);
|
||||
await processRunner.run(command, <String>[versionFlag]);
|
||||
if (result.exitCode != 0) {
|
||||
return false;
|
||||
}
|
||||
|
Reference in New Issue
Block a user