getVersionCli static method
Implementation
static Future<String?> getVersionCli({bool disableLog = false}) async {
try {
var scriptFile = Platform.script.toFilePath();
var paths = scriptFile.split('/');
paths.removeRange(paths.length - 5, paths.length - 1);
scriptFile = paths.join('/');
var pathToPubLock = join(dirname(scriptFile), 'pubspec.lock');
final file = File(pathToPubLock);
var text = loadYaml(await file.readAsString());
if (text['packages']['gen_cli'] == null) {
if (isDevVersion()) {
if (!disableLog) {
LogService.info('Development version');
}
}
return null;
}
var version = text['packages']['gen_cli']['version'].toString();
return version;
} on Exception catch (_) {
if (!disableLog) {
LogService.error('没有找到已安装版本。');
}
return null;
}
}