Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 25 additions & 23 deletions cmd/aliases/powershell.ps1
Original file line number Diff line number Diff line change
@@ -1,28 +1,30 @@
# Hugo Version Manager: override path to the hugo executable.
function Hugo-Override {
Set-Variable -Name "hvm_show_status" -Value $true
Set-Variable -Name "hugo_bin" -Value $(hvm status --printExecPathCached)
If ($hugo_bin) {
If ($hvm_show_status) {
Write-Host "Hugo version management is enabled in this directory."
Write-Host "Run 'hvm status' for details, or 'hvm disable' to disable.`n"
$hvm_show_status = $true
$HVMBin = hvm status --printExecPathCached 2>$null
Comment thread
jmooring marked this conversation as resolved.
if ($HVMBin) {
if ($hvm_show_status) {
$InformationPreference = 'Continue'
Write-Host "Hugo version management is enabled in this directory."
Write-Host "Run 'hvm status' for details, or 'hvm disable' to disable.`n"
}
} else {
$HVMBin = hvm status --printExecPath 2>$null
Comment thread
jmooring marked this conversation as resolved.
if ($HVMBin) {
hvm use --useVersionInDotFile
if ($LASTEXITCODE -ne 0) { return }
} else {
$HugoCommand = Get-Command -Name hugo.exe -ErrorAction SilentlyContinue -CommandType Application
if ($HugoCommand) {
$HVMBin = $HugoCommand.Definition
}
}
}
Comment thread
jmooring marked this conversation as resolved.
Comment thread
jmooring marked this conversation as resolved.
& "$hugo_bin" $args
} Else {
Set-Variable -Name "hugo_bin" -Value $(hvm status --printExecPath)
If ($hugo_bin) {
hvm use --useVersionInDotFile
if ($lastexitcode) {
return
}
} Else {
Set-Variable -Name "hugo_bin" -Value $((gcm hugo.exe).Path 2> $null)
If ($hugo_bin) {
& "$hugo_bin" $args
} Else {
Write-Error "Command not found"
}
if ($HVMBin) {
& $HVMBin @args
} else {
$global:LASTEXITCODE = 1
Write-Error "Command not found." -ErrorAction Continue
}
}
}
Set-Alias hugo Hugo-Override
Set-Alias -Name hugo -Value Hugo-Override -Force
Loading