1
0
mirror of https://github.com/sstephenson/bats.git synced 2024-11-17 03:32:27 +01:00

Add installer

This commit is contained in:
Sam Stephenson 2011-12-29 18:48:33 -06:00
parent 18b0517659
commit cefd684545
2 changed files with 49 additions and 0 deletions

View File

@ -119,3 +119,17 @@ in the test file.
* `$BATS_TMPDIR` is the location to a directory that may be used to
store temporary files.
### Installing Bats
Check out a copy of the Bats repository. Then, either add the Bats
`bin` directory to your `$PATH`, or run the provided `install.sh`
command with the location to the prefix in which you want to install
Bats. For example, to install Bats into `/usr/local`,
$ git clone https://github.com/sstephenson/bats.git
$ cd bats
$ ./install.sh /usr/local
Note that you may need to run `install.sh` with `sudo` if you do not
have permission to write to the installation prefix.

35
install.sh Executable file
View File

@ -0,0 +1,35 @@
#!/usr/bin/env bash
set -e
resolve_link() {
$(type -p greadlink readlink | head -1) "$1"
}
abs_dirname() {
local cwd="$(pwd)"
local path="$1"
while [ -n "$path" ]; do
cd "${path%/*}"
local name="${path##*/}"
path="$(resolve_link "$name" || true)"
done
pwd
cd "$cwd"
}
PREFIX="$1"
if [ -z "$1" ]; then
{ echo "usage: $0 <prefix>"
echo " e.g. $0 /usr/local"
} >&2
exit 1
fi
BATS_ROOT="$(abs_dirname "$0")"
mkdir -p "$PREFIX"/{bin,libexec}
cp -R "$BATS_ROOT"/bin/* "$PREFIX"/bin
cp -R "$BATS_ROOT"/libexec/* "$PREFIX"/libexec
echo "Installed Bats to $PREFIX/bin/bats"