Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

Commit

Permalink
fix(CheckProgramInstalled): Find Windows executables correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
iakdis committed Feb 27, 2023
1 parent 8654326 commit 313d5e0
Showing 1 changed file with 25 additions and 15 deletions.
40 changes: 25 additions & 15 deletions lib/src/utils/program_installed.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,31 @@ void checkProgramInstalled({
final errorText = AppLocalizations.of(context)!.error_executableNotFound(
'${executable[0].toUpperCase()}${executable.substring(1)}', '"$command"');

// Try to get executable
await shell.run('which $executable').then((value) {
// Executable found, set it
finalExecutable = value.outText;
}).catchError((object) async {
// If no executable found, check for Linux Flatpak sandbox issue
if (Platform.isLinux) {
await shell.run('flatpak-spawn --host which $executable').then((value) {
// If platform is Flatpak and no error, executable found
finalExecutable = value.outText;
}).catchError((object) {
// If platform is Flatpak but still not found, not installed
});
}
});
if (Platform.isWindows) {
// Try to get executable
await which(executable).then((value) {
// Executable found, set it
finalExecutable = value ?? '';
}).catchError((object) async {
// Not installed
});
} else {
// Try to get executable
await shell.run('which $executable').then((value) {
// Executable found, set it
finalExecutable = value.outText;
}).catchError((object) async {
// If no executable found, check for Linux Flatpak sandbox issue
if (Platform.isLinux) {
await shell.run('flatpak-spawn --host which $executable').then((value) {
// If platform is Flatpak and no error, executable found
finalExecutable = value.outText;
}).catchError((object) {
// If platform is Flatpak but still not found, not installed
});
}
});
}

if (finalExecutable.isEmpty) {
notFound?.call();
Expand Down

0 comments on commit 313d5e0

Please sign in to comment.