Skip to content

Commit

Permalink
cmd/aliases: Exit gracefully when version not in repo
Browse files Browse the repository at this point in the history
Exit gracefully when the dot file contains a version that is not in the
repository.

Closes #40
  • Loading branch information
jmooring committed Sep 24, 2023
1 parent c83cbcf commit 762d508
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 7 deletions.
4 changes: 3 additions & 1 deletion cmd/hvm/alias_scripts/bash.sh → cmd/hvm/aliases/bash.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ hugo() {
fi
else
if hugo_bin=$(hvm status --printExecPath); then
hvm use --useVersionInDotFile
if ! hvm use --useVersionInDotFile; then
return 1
fi
else
if ! hugo_bin=$(which hugo); then
>&2 printf "Command not found.\\n"
Expand Down
4 changes: 3 additions & 1 deletion cmd/hvm/alias_scripts/fish.sh → cmd/hvm/aliases/fish.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ hugo() {
fi
else
if hugo_bin=$(hvm status --printExecPath); then
hvm use --useVersionInDotFile
if ! hvm use --useVersionInDotFile; then
return 1
fi
else
if ! hugo_bin=$(which hugo); then
>&2 printf "Command not found.\\n"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ function Hugo-Override {
Set-Variable -Name "hugo_bin" -Value $(hvm status --printExecPath)
If ($hugo_bin) {
hvm use --useVersionInDotFile
if ($lastexitcode) {
return 1
}
} Else {
Set-Variable -Name "hugo_bin" -Value $((gcm hugo.exe).Path 2> $null)
If ($hugo_bin) {
Expand Down
4 changes: 3 additions & 1 deletion cmd/hvm/alias_scripts/zsh.sh → cmd/hvm/aliases/zsh.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ hugo() {
fi
else
if hugo_bin=$(hvm status --printExecPath); then
hvm use --useVersionInDotFile
if ! hvm use --useVersionInDotFile; then
return 1
fi
else
if ! hugo_bin=$(which hugo); then
>&2 printf "Command not found.\\n"
Expand Down
2 changes: 1 addition & 1 deletion cmd/hvm/bash.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"github.com/spf13/cobra"
)

//go:embed alias_scripts/bash.sh
//go:embed aliases/bash.sh
var bashScript string

// bashCmd represents the bash command
Expand Down
2 changes: 1 addition & 1 deletion cmd/hvm/fish.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"github.com/spf13/cobra"
)

//go:embed alias_scripts/fish.sh
//go:embed aliases/fish.sh
var fishScript string

// fishCmd represents the fish command
Expand Down
2 changes: 1 addition & 1 deletion cmd/hvm/powershell.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"github.com/spf13/cobra"
)

//go:embed alias_scripts/powershell.ps1
//go:embed aliases/powershell.ps1
var powershellScript string

// powershellCmd represents the powershell command
Expand Down
2 changes: 1 addition & 1 deletion cmd/hvm/zsh.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"github.com/spf13/cobra"
)

//go:embed alias_scripts/zsh.sh
//go:embed aliases/zsh.sh
var zshScript string

// zshCmd represents the zsh command
Expand Down

0 comments on commit 762d508

Please sign in to comment.