Skip to content

Commit

Permalink
Merge pull request #90 from jetstack/install_script_already_installed
Browse files Browse the repository at this point in the history
Throw error if jsctl was already installed at another location
  • Loading branch information
inteon authored Feb 15, 2023
2 parents e07d6d8 + 45a606f commit c8067e2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ $Target = if ($ENV:OS -eq "Windows_NT") {

$DownloadUrl = "https://github.com/jetstack/jsctl/releases/latest/download/${Target}.tar.gz"

$CurrentInstall = (Get-Command jsctl).Definition
if (!(Test-Path $JsctlExe) -and ($CurrentInstall -ne $JsctlExe)) {
throw "Error: tried to install jsctl to "$JsctlExe", but is already installed at "$CurrentInstall"."
}

if (!(Test-Path $BinDir)) {
New-Item $BinDir -ItemType Directory | Out-Null
}
Expand Down
6 changes: 6 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ jsctl_install="${JSCTL_INSTALL:-$HOME/.jsctl}"
bin_dir="$jsctl_install/bin"
bin="$bin_dir/$target_file"

if current_install=$( command -v jsctl ) && [ ! -x "$bin" ] && [ "$current_install" != "$bin" ]; then
echo "failed to install jsctl to \"$bin\"" >&2
echo "jsctl is already installed in another location: \"$current_install\"" >&2
exit 1
fi

if [ ! -d "$bin_dir" ]; then
mkdir -p "$bin_dir"
fi
Expand Down

0 comments on commit c8067e2

Please sign in to comment.