forked from apicollective/apibuilder-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·40 lines (31 loc) · 837 Bytes
/
install.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/env bash
# derived from install script in https://github.com/sstephenson/bats
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
API_BUILDER_ROOT="$(abs_dirname "$0")"
mkdir -p "$PREFIX"/{bin,src}
cp -R "$API_BUILDER_ROOT"/bin/* "$PREFIX"/bin
cp -R "$API_BUILDER_ROOT"/src/* "$PREFIX"/src
eval "./util/update-library-path.rb $PREFIX/bin/apibuilder ${PREFIX}/src/apibuilder-cli.rb"
eval "chmod +x $PREFIX/bin/apibuilder"
echo "Installed API_BUILDER_CLI to $PREFIX/bin/apibuilder"