Skip to content

Commit

Permalink
Revert "Simplify update checker"
Browse files Browse the repository at this point in the history
This reverts commit 68c6422.
  • Loading branch information
corbindavenport committed May 4, 2023
1 parent 3101187 commit 26d62ca
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions bin/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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.');
}
Expand Down Expand Up @@ -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;
Expand All @@ -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) {
Expand Down

0 comments on commit 26d62ca

Please sign in to comment.