Skip to content

Commit a2a1c63

Browse files
ASP.NET Push Botunknown
authored andcommitted
⬆️ dnvm.ps1, dnvm.cmd, dnvm.sh
Source: aspnet/dnvm@184a725
1 parent b1a1f52 commit a2a1c63

File tree

2 files changed

+33
-18
lines changed

2 files changed

+33
-18
lines changed

dnvm.ps1

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ function _WriteOut {
6767

6868
### Constants
6969
$ProductVersion="1.0.0"
70-
$BuildVersion="beta7-10410"
70+
$BuildVersion="beta8-15502"
7171
$Authors="Microsoft Open Technologies, Inc."
7272

7373
# If the Version hasn't been replaced...
@@ -359,7 +359,7 @@ function Get-RuntimeAlias {
359359
if($Aliases -eq $null) {
360360
_WriteDebug "Scanning for aliases in $AliasesDir"
361361
if(Test-Path $AliasesDir) {
362-
$Aliases = @(Get-ChildItem ($UserHome + "\alias\") | Select-Object @{label='Alias';expression={$_.BaseName}}, @{label='Name';expression={Get-Content $_.FullName }})
362+
$Aliases = @(Get-ChildItem ($UserHome + "\alias\") | Select-Object @{label='Alias';expression={$_.BaseName}}, @{label='Name';expression={Get-Content $_.FullName }}, @{label='Orphan';expression={-Not (Test-Path ($RuntimesDir + "\" + (Get-Content $_.FullName)))}})
363363
} else {
364364
$Aliases = @()
365365
}
@@ -396,18 +396,20 @@ function Get-RuntimeAliasOrRuntimeInfo(
396396
filter List-Parts {
397397
param($aliases)
398398

399-
$binDir = Join-Path $_.FullName "bin"
400-
if (!(Test-Path $binDir)) {
401-
return
399+
$location = ""
400+
401+
$binDir = Join-Path $_.FullName "bin"
402+
if ((Test-Path $binDir)) {
403+
$location = $_.Parent.FullName
402404
}
403-
$active = IsOnPath $binDir
404-
405+
$active = IsOnPath $binDir
406+
405407
$fullAlias=""
406408
$delim=""
407409

408410
foreach($alias in $aliases) {
409411
if($_.Name.Split('\', 2) -contains $alias.Name) {
410-
$fullAlias += $delim + $alias.Alias
412+
$fullAlias += $delim + $alias.Alias + (&{if($alias.Orphan){" (missing)"}})
411413
$delim = ", "
412414
}
413415
}
@@ -416,7 +418,7 @@ filter List-Parts {
416418
$parts2 = $parts1[0].Split('-', 4)
417419

418420
if($parts1[0] -eq "$RuntimePackageName-mono") {
419-
$parts2 += "linux/darwin"
421+
$parts2 += "linux/osx"
420422
$parts2 += "x86/x64"
421423
}
422424

@@ -426,7 +428,7 @@ filter List-Parts {
426428
Runtime = $parts2[1]
427429
OperatingSystem = $parts2[2]
428430
Architecture = $parts2[3]
429-
Location = $_.Parent.FullName
431+
Location = $location
430432
Alias = $fullAlias
431433
}
432434
}
@@ -925,7 +927,7 @@ function dnvm-help {
925927
_WriteOut -ForegroundColor $ColorScheme.Help_Header "commands: "
926928
Get-Command "$CommandPrefix*" |
927929
ForEach-Object {
928-
if($Host.Version.MajorVersion -lt 3) {
930+
if($Host.Version.Major -lt 3) {
929931
$h = Get-Help $_.Name
930932
} else {
931933
$h = Get-Help $_.Name -ShowWindow:$false
@@ -978,6 +980,10 @@ function dnvm-list {
978980
}
979981
}
980982

983+
$aliases | Where-Object {$_.Orphan} | ForEach-Object {
984+
$items += $_ | Select-Object @{label='Name';expression={$_.Name}}, @{label='FullName';expression={Join-Path $RuntimesDir $_.Name}} | List-Parts $aliases
985+
}
986+
981987
if($PassThru) {
982988
$items
983989
} else {

dnvm.sh

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Source this file from your .bash-profile or script to use
33

44
# "Constants"
5-
_DNVM_BUILDNUMBER="beta7-10410"
5+
_DNVM_BUILDNUMBER="beta8-15502"
66
_DNVM_AUTHORS="Microsoft Open Technologies, Inc."
77
_DNVM_RUNTIME_PACKAGE_NAME="dnx"
88
_DNVM_RUNTIME_FRIENDLY_NAME=".NET Execution Environment"
@@ -736,7 +736,7 @@ dnvm()
736736
[[ ! -d $_DNVM_USER_PACKAGES ]] && echo "$_DNVM_RUNTIME_FRIENDLY_NAME is not installed." && return 1
737737

738738
local searchGlob="$_DNVM_RUNTIME_PACKAGE_NAME-*"
739-
local runtimes="$(find $_DNVM_USER_PACKAGES -name "$searchGlob" \( -type d -or -type l \) -prune -exec basename {} \; | sort -t. -k2 -k3 -k4 -k1)"
739+
local runtimes="$(find $_DNVM_USER_PACKAGES -name "$searchGlob" \( -type d -or -type l \) -prune -exec basename {} \;)"
740740

741741
[[ -z $runtimes ]] && echo 'No runtimes installed. You can run `dnvm install latest` or `dnvm upgrade` to install a runtime.' && return
742742

@@ -752,7 +752,12 @@ dnvm()
752752
local format="%-20s %s\n"
753753
if [ -d "$_DNVM_ALIAS_DIR" ]; then
754754
for __dnvm_file in $(find "$_DNVM_ALIAS_DIR" -name *.alias); do
755-
arr[$i]="$(basename $__dnvm_file | sed 's/\.alias//')/$(cat $__dnvm_file)"
755+
if [ ! -d "$_DNVM_USER_PACKAGES/$(cat $__dnvm_file)" ]; then
756+
arr[$i]="$(basename $__dnvm_file | sed 's/\.alias//')/missing/$(cat $__dnvm_file)"
757+
runtimes="$runtimes $(cat $__dnvm_file)"
758+
else
759+
arr[$i]="$(basename $__dnvm_file | sed 's/\.alias//')/$(cat $__dnvm_file)"
760+
fi
756761
let i+=1
757762
done
758763
fi
@@ -767,8 +772,8 @@ dnvm()
767772
printf "$formatString" "------" "-------" "-------" "----" "---------------" "-----"
768773
fi
769774

770-
local formattedHome=`(echo $_DNVM_USER_PACKAGES | sed s=$HOME=~=g)`
771-
for f in `echo $runtimes`; do
775+
for f in `echo $runtimes | sort -t. -k2 -k3 -k4 -k1`; do
776+
local formattedHome=`(echo $_DNVM_USER_PACKAGES | sed s=$HOME=~=g)`
772777
local active=""
773778
[[ $PATH == *"$_DNVM_USER_PACKAGES/$f/bin"* ]] && local active=" *"
774779
local pkgRuntime=$(__dnvm_package_runtime "$f")
@@ -780,9 +785,13 @@ dnvm()
780785
local alias=""
781786
local delim=""
782787
for i in "${arr[@]}"; do
783-
if [[ ${i#*/} == "$pkgName.$pkgVersion" ]]; then
784-
alias+="$delim${i%/*}"
788+
if [[ ${i##*/} == "$pkgName.$pkgVersion" ]]; then
789+
alias+="$delim${i%%/*}"
785790
delim=", "
791+
if [[ "${i%/*}" =~ \/missing$ ]]; then
792+
alias+=" (missing)"
793+
formattedHome=""
794+
fi
786795
fi
787796
done
788797

0 commit comments

Comments
 (0)