getVersionCli static method

Future<String?> getVersionCli({
  1. bool disableLog = false,
})

Implementation

static Future<String?> getVersionCli({bool disableLog = false}) async {
  try {
    var scriptFile = Platform.script.toFilePath();
    var pathToPubLock = join(dirname(scriptFile), '../pubspec.lock');
    final file = File(pathToPubLock);
    var text = loadYaml(await file.readAsString());
    if (text['packages']['get_cli'] == null) {
      if (isDevVersion()) {
        if (!disableLog) {
          LogService.info('Development version');
        }
      }
      return null;
    }
    var version = text['packages']['get_cli']['version'].toString();
    return version;
  } on Exception catch (_) {
    if (!disableLog) {
      LogService.error(
          Translation(LocaleKeys.error_cli_version_not_found).tr);
    }
    return null;
  }
}