forked from software-mansion/protostar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·67 lines (53 loc) · 1.75 KB
/
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/usr/bin/env bash
set -e
echo Installing protostar
PROTOSTAR_DIR=${PROTOSTAR_DIR-"$HOME/.protostar"}
mkdir -p "$PROTOSTAR_DIR"
PLATFORM="$(uname -s)"
case $PLATFORM in
Linux)
PLATFORM="Linux"
;;
Darwin)
PLATFORM="macOS"
;;
*)
echo "unsupported platform: $PLATFORM"
exit 1
;;
esac
PROTOSTAR_REPO="https://github.com/software-mansion/protostar"
echo Retrieving the latest version from $PROTOSTAR_REPO...
LATEST_RELEASE=$(curl -L -s -H 'Accept: application/json' "${PROTOSTAR_REPO}/releases/latest")
LATEST_VERSION=$(echo $LATEST_RELEASE | sed -e 's/.*"tag_name":"\([^"]*\)".*/\1/')
echo Using version $LATEST_VERSION
LATEST_RELEASE_URL="${PROTOSTAR_REPO}/releases/download/${LATEST_VERSION}"
PROTOSTAR_TARBALL_NAME="protostar-${PLATFORM}.tar.gz"
TARBALL_DOWNLOAD_URL="${LATEST_RELEASE_URL}/${PROTOSTAR_TARBALL_NAME}"
echo "Downloading protostar from ${TARBALL_DOWNLOAD_URL}"
curl -L $TARBALL_DOWNLOAD_URL | tar -xvzC $PROTOSTAR_DIR
PROTOSTAR_BINARY_DIR="${PROTOSTAR_DIR}/dist/protostar"
PROTOSTAR_BINARY="${PROTOSTAR_BINARY_DIR}/protostar"
chmod +x $PROTOSTAR_BINARY
case $SHELL in
*/zsh)
PROFILE=$HOME/.zshrc
PREF_SHELL=zsh
;;
*/bash)
PROFILE=$HOME/.bashrc
PREF_SHELL=bash
;;
*/fish)
PROFILE=$HOME/.config/fish/config.fish
PREF_SHELL=fish
;;
*)
echo "error: could not detect shell, manually add ${PROTOSTAR_BINARY_DIR} to your PATH."
exit 1
esac
if [[ ":$PATH:" != *":${PROTOSTAR_BINARY_DIR}:"* ]]; then
echo >> $PROFILE && echo "export PATH=\"\$PATH:$PROTOSTAR_BINARY_DIR\"" >> $PROFILE
fi
echo && echo "Detected your preferred shell is ${PREF_SHELL} and added protostar to PATH. Run 'source ${PROFILE}' or start a new terminal session to use protostar."
echo "Then, simply run 'protostar --help' "