1
0
mirror of https://github.com/sstephenson/bats.git synced 2024-12-25 14:09:43 +01:00
1 Install Bats Using GNU Stow
Todd A. Jacobs edited this page 2014-08-22 22:27:29 -07:00

Purpose

Sometimes you want to install a package like Bats, but you either don't want to install it in a system directory like /usr/local because you don't have root privileges, or you want to be able to manage multiple versions cleanly. GNU Stow can handle both use cases well, and installing or upgrading Bats with Stow is trivial.

Installing as Root

stow=/usr/local/stow
version=$(libexec/bats -v | tr A-Z a-z | tr ' ' -)

# Unstow older versions of Bats.
shopt -s nullglob
old_bats=(`find "$stow" -type d -name bats-\*`)
for package in "${old_bats[@]}"; do
    sudo stow --dir="$stow" --delete $(basename "$package")
done

sudo ./install.sh "${stow}/${version}"
sudo stow --dir="$stow" --restow "$version"

Installing as User

mkdir ~/stow
stow=~/stow
version=$(libexec/bats -v | tr A-Z a-z | tr ' ' -)

# Unstow older versions of Bats.
shopt -s nullglob
old_bats=(`find "$stow" -type d -name bats-\*`)
for package in "${old_bats[@]}"; do
    stow --dir="$stow" --delete $(basename "$package")
done

./install.sh "${stow}/${version}"
stow --dir="$stow" --restow "$version"