Skip to content

Commit

Permalink
Fix get command when moving to bin
Browse files Browse the repository at this point in the history
  • Loading branch information
insign committed May 26, 2023
1 parent e19d425 commit 97e6d22
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 12 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
## v0.52.0
- Fix get command when moving to bin
## v0.51.0
- Separate Flatpak, Snap and AppImage functions and adjusts others files to this change. fix #103
## v0.50.0
Expand Down
22 changes: 12 additions & 10 deletions lib/commands/devs/get.dart
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ class GetCommand extends Command {

int actualProgress = 0;
int lastProgress = 0;
final File file = await downloader.download(
File file = await downloader.download(
url: url,
destination: destination,
userAgent: argResults!['user-agent'],
Expand Down Expand Up @@ -185,24 +185,26 @@ class GetCommand extends Command {
if (argResults!['bin'] == true || argResults!['exec'] == true) {
final runner = Run();

if (argResults!['exec'] == true && !Platform.isWindows) {
bool asExec = await runner.asExec(file.path, sudo: await Executable('sudo').exists());
if (asExec) {
Logger.info('Made $file executable');
} else {
throw Exception('Failed to make $file executable');
}
}

if (argResults!['bin'] == true) {
// @FIXME shouldn't $destination be set instead use this logic?
final File? toBin = await moveToBin(file, runner: runner, sudo: await Executable('sudo').exists());

if (toBin != null) {
Logger.info('Installed $file to bin folder: ${toBin.path}');
file = toBin;
} else {
throw Exception('Failed to install $file to bin folder');
}
}

if (argResults!['exec'] == true && !Platform.isWindows) {
bool asExec = await runner.asExec(file.path, sudo: await Executable('sudo').exists());
if (asExec) {
Logger.info('Made $file executable');
} else {
throw Exception('Failed to make $file executable');
}
}
}

print(file.absolute.path);
Expand Down
2 changes: 1 addition & 1 deletion lib/pubspec.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
const name = 'xpm';
const description =
'Universal package manager for any unix-like distro including macOS. Also experimental Windows support.';
const version = '0.51.0';
const version = '0.52.0';
const homepage = 'https://xpm.link';
const repository = 'https://github.com/verseles/xpm';
const executables = '{xpm: null}';
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: xpm
description: Universal package manager for any unix-like distro including macOS. Also experimental Windows support.
version: 0.51.0
version: 0.52.0
homepage: https://xpm.link
repository: https://github.com/verseles/xpm
executables:
Expand Down

0 comments on commit 97e6d22

Please sign in to comment.