mirror of
https://github.com/sstephenson/bats.git
synced 2024-11-17 11:42:33 +01:00
Add installer
This commit is contained in:
parent
18b0517659
commit
cefd684545
14
README.md
14
README.md
|
@ -119,3 +119,17 @@ in the test file.
|
||||||
* `$BATS_TMPDIR` is the location to a directory that may be used to
|
* `$BATS_TMPDIR` is the location to a directory that may be used to
|
||||||
store temporary files.
|
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
35
install.sh
Executable 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"
|
Loading…
Reference in New Issue
Block a user