⬆️ dnvm.ps1, dnvm.cmd, dnvm.sh

Source: aspnet/dnvm@184a7254d8
This commit is contained in:
ASP.NET Push Bot 2015-08-24 09:56:55 -07:00 committed by unknown
parent b1a1f52331
commit a2a1c637c9
2 changed files with 33 additions and 18 deletions

View File

@ -67,7 +67,7 @@ function _WriteOut {
### Constants
$ProductVersion="1.0.0"
$BuildVersion="beta7-10410"
$BuildVersion="beta8-15502"
$Authors="Microsoft Open Technologies, Inc."
# If the Version hasn't been replaced...
@ -359,7 +359,7 @@ function Get-RuntimeAlias {
if($Aliases -eq $null) {
_WriteDebug "Scanning for aliases in $AliasesDir"
if(Test-Path $AliasesDir) {
$Aliases = @(Get-ChildItem ($UserHome + "\alias\") | Select-Object @{label='Alias';expression={$_.BaseName}}, @{label='Name';expression={Get-Content $_.FullName }})
$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)))}})
} else {
$Aliases = @()
}
@ -396,18 +396,20 @@ function Get-RuntimeAliasOrRuntimeInfo(
filter List-Parts {
param($aliases)
$binDir = Join-Path $_.FullName "bin"
if (!(Test-Path $binDir)) {
return
$location = ""
$binDir = Join-Path $_.FullName "bin"
if ((Test-Path $binDir)) {
$location = $_.Parent.FullName
}
$active = IsOnPath $binDir
$active = IsOnPath $binDir
$fullAlias=""
$delim=""
foreach($alias in $aliases) {
if($_.Name.Split('\', 2) -contains $alias.Name) {
$fullAlias += $delim + $alias.Alias
$fullAlias += $delim + $alias.Alias + (&{if($alias.Orphan){" (missing)"}})
$delim = ", "
}
}
@ -416,7 +418,7 @@ filter List-Parts {
$parts2 = $parts1[0].Split('-', 4)
if($parts1[0] -eq "$RuntimePackageName-mono") {
$parts2 += "linux/darwin"
$parts2 += "linux/osx"
$parts2 += "x86/x64"
}
@ -426,7 +428,7 @@ filter List-Parts {
Runtime = $parts2[1]
OperatingSystem = $parts2[2]
Architecture = $parts2[3]
Location = $_.Parent.FullName
Location = $location
Alias = $fullAlias
}
}
@ -925,7 +927,7 @@ function dnvm-help {
_WriteOut -ForegroundColor $ColorScheme.Help_Header "commands: "
Get-Command "$CommandPrefix*" |
ForEach-Object {
if($Host.Version.MajorVersion -lt 3) {
if($Host.Version.Major -lt 3) {
$h = Get-Help $_.Name
} else {
$h = Get-Help $_.Name -ShowWindow:$false
@ -978,6 +980,10 @@ function dnvm-list {
}
}
$aliases | Where-Object {$_.Orphan} | ForEach-Object {
$items += $_ | Select-Object @{label='Name';expression={$_.Name}}, @{label='FullName';expression={Join-Path $RuntimesDir $_.Name}} | List-Parts $aliases
}
if($PassThru) {
$items
} else {

23
dnvm.sh
View File

@ -2,7 +2,7 @@
# Source this file from your .bash-profile or script to use
# "Constants"
_DNVM_BUILDNUMBER="beta7-10410"
_DNVM_BUILDNUMBER="beta8-15502"
_DNVM_AUTHORS="Microsoft Open Technologies, Inc."
_DNVM_RUNTIME_PACKAGE_NAME="dnx"
_DNVM_RUNTIME_FRIENDLY_NAME=".NET Execution Environment"
@ -736,7 +736,7 @@ dnvm()
[[ ! -d $_DNVM_USER_PACKAGES ]] && echo "$_DNVM_RUNTIME_FRIENDLY_NAME is not installed." && return 1
local searchGlob="$_DNVM_RUNTIME_PACKAGE_NAME-*"
local runtimes="$(find $_DNVM_USER_PACKAGES -name "$searchGlob" \( -type d -or -type l \) -prune -exec basename {} \; | sort -t. -k2 -k3 -k4 -k1)"
local runtimes="$(find $_DNVM_USER_PACKAGES -name "$searchGlob" \( -type d -or -type l \) -prune -exec basename {} \;)"
[[ -z $runtimes ]] && echo 'No runtimes installed. You can run `dnvm install latest` or `dnvm upgrade` to install a runtime.' && return
@ -752,7 +752,12 @@ dnvm()
local format="%-20s %s\n"
if [ -d "$_DNVM_ALIAS_DIR" ]; then
for __dnvm_file in $(find "$_DNVM_ALIAS_DIR" -name *.alias); do
arr[$i]="$(basename $__dnvm_file | sed 's/\.alias//')/$(cat $__dnvm_file)"
if [ ! -d "$_DNVM_USER_PACKAGES/$(cat $__dnvm_file)" ]; then
arr[$i]="$(basename $__dnvm_file | sed 's/\.alias//')/missing/$(cat $__dnvm_file)"
runtimes="$runtimes $(cat $__dnvm_file)"
else
arr[$i]="$(basename $__dnvm_file | sed 's/\.alias//')/$(cat $__dnvm_file)"
fi
let i+=1
done
fi
@ -767,8 +772,8 @@ dnvm()
printf "$formatString" "------" "-------" "-------" "----" "---------------" "-----"
fi
local formattedHome=`(echo $_DNVM_USER_PACKAGES | sed s=$HOME=~=g)`
for f in `echo $runtimes`; do
for f in `echo $runtimes | sort -t. -k2 -k3 -k4 -k1`; do
local formattedHome=`(echo $_DNVM_USER_PACKAGES | sed s=$HOME=~=g)`
local active=""
[[ $PATH == *"$_DNVM_USER_PACKAGES/$f/bin"* ]] && local active=" *"
local pkgRuntime=$(__dnvm_package_runtime "$f")
@ -780,9 +785,13 @@ dnvm()
local alias=""
local delim=""
for i in "${arr[@]}"; do
if [[ ${i#*/} == "$pkgName.$pkgVersion" ]]; then
alias+="$delim${i%/*}"
if [[ ${i##*/} == "$pkgName.$pkgVersion" ]]; then
alias+="$delim${i%%/*}"
delim=", "
if [[ "${i%/*}" =~ \/missing$ ]]; then
alias+=" (missing)"
formattedHome=""
fi
fi
done