getCommandVersion method

Future<String?> getCommandVersion(
  1. String command, {
  2. List<String> versionArgs = const <String>['--version'],
})

Get the version of a command

Implementation

Future<String?> getCommandVersion(
  String command, {
  List<String> versionArgs = const <String>['--version'],
}) async {
  try {
    final ProcessResult result = await run(command, versionArgs);
    if (result.success) {
      return result.stdout.trim().split('\n').first;
    }
    return null;
  } catch (e) {
    return null;
  }
}