diff --git a/bin/main.dart b/bin/main.dart index 5a54bfb..d4a33c2 100644 --- a/bin/main.dart +++ b/bin/main.dart @@ -14,12 +14,16 @@ String baseRepo = 'corbindavenport/nexus-tools'; // Function for checking for update Future checkUpdate() async { - print('[INFO] Your installed version of Nexus Tools: $appVersion'); var net = Uri.parse('https://api.github.com/repos/$baseRepo/releases/latest'); try { var data = await http.read(net); var parsedData = json.decode(data); - print('[INFO] Latest available version: ' + parsedData['tag_name'] + '[INFO] Get the latest version: https://github.com/$baseRepo/blob/main/README.md\n'); + // Compare versions + if (double.parse(parsedData['tag_name']) > appVersion) { + print('[INFO] Nexus Tools update available! https://github.com/$baseRepo/blob/main/README.md'); + } else { + print('[INFO] You have the latest version of Nexus Tools.'); + } } catch (e) { print('[EROR] Could not check for updates.'); } @@ -145,6 +149,7 @@ Future removePlatformTools() async { return; } // Delete primary directory if it exists + // TODO: Add support for new directory on Windows // Nexus Tools 3.2+ (August 2016-Present) installs binaries in ~/.nexustools var dir = nexusToolsDir(); var installExists = false; @@ -153,8 +158,6 @@ Future removePlatformTools() async { // Proceed with deletion await io.Directory(dir).delete(recursive: true); print('[ OK ] Deleted directory at $dir.'); - } else { - print('[ OK ] No installation found at $dir'); } // Windows-specific functions if (io.Platform.isWindows) {