Skip to content

Commit

Permalink
Refactor aria2_path() to file_path()
Browse files Browse the repository at this point in the history
  • Loading branch information
r15ch13 committed Aug 8, 2018
1 parent b8d9d9c commit 0f46401
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions lib/core.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -96,23 +96,27 @@ function installed_apps($global) {
}
}

function aria2_path() {
# normal path to executable
$aria2 = "$(versiondir 'aria2' 'current' $false)\aria2c.exe"
if(Test-Path($aria2)) {
return $aria2
function file_path($app, $file) {
# normal path to file
$path = "$(versiondir $app 'current' $false)\$file"
if(Test-Path($path)) {
return $path
}

# global path to executable
$aria2 = "$(versiondir 'aria2' 'current' $true)\aria2c.exe"
if(Test-Path($aria2)) {
return $aria2
# global path to file
$path = "$(versiondir $app 'current' $true)\$file"
if(Test-Path($path)) {
return $path
}

# not found
return $null
}

function aria2_path() {
return (file_path 'aria2' 'aria2c.exe')
}

function aria2_installed() {
return ![String]::IsNullOrWhiteSpace("$(aria2_path)")
}
Expand Down

0 comments on commit 0f46401

Please sign in to comment.