Update install script for M1 Macs and Homebrew (#3496)
* Update install script for M1 Macs and Homebrew Hi! I saw this comment https://github.com/tuist/tuist/issues/3299#issuecomment-900088290 while exploring the repo and I thought I might make a small fix. I'm a little unsure about a couple things (I'm primarily a fish user so my bash is a little rusty 😅). Completely open to feedback though! * Update patch to not depend on homebrew * Move to not depending on homebrew for INSTALL_DIR * Address Feedback * Tiny fixes 1. Turns out, `bash -c` expects quotes around arguments 2. Add a sudo check for making the installation directory in case it doesn't exist and it needs root access * fix: spacing Co-authored-by: Daniele Formichelli <df@bendingspoons.com>
This commit is contained in:
parent
dd37317ee5
commit
37993ca156
|
@ -33,16 +33,27 @@ ohai "Unzipping tuistenv..."
|
|||
unzip -o /tmp/tuistenv.zip -d /tmp/tuistenv > /dev/null
|
||||
ohai "Installing tuistenv..."
|
||||
|
||||
if [[ ! -d "/usr/local/bin" ]]; then
|
||||
mkdir -p /usr/local/bin/
|
||||
INSTALL_DIR="/usr/local/bin"
|
||||
|
||||
sudo_if_install_dir_not_writeable() {
|
||||
local command="$1"
|
||||
if [ -w $INSTALL_DIR ]; then
|
||||
bash -c "${command}"
|
||||
else
|
||||
bash -c "sudo ${command}"
|
||||
fi
|
||||
}
|
||||
|
||||
if [[ ! -d $INSTALL_DIR ]]; then
|
||||
sudo_if_install_dir_not_writeable "mkdir -p ${INSTALL_DIR}"
|
||||
fi
|
||||
|
||||
if [[ -f "/usr/local/bin/tuist" ]]; then
|
||||
rm /usr/local/bin/tuist
|
||||
if [[ -f "${INSTALL_DIR}/tuist" ]]; then
|
||||
sudo_if_install_dir_not_writeable "rm ${INSTALL_DIR}/tuist"
|
||||
fi
|
||||
|
||||
mv /tmp/tuistenv/tuistenv /usr/local/bin/tuist
|
||||
chmod +x /usr/local/bin/tuist
|
||||
sudo_if_install_dir_not_writeable "mv /tmp/tuistenv/tuistenv \"${INSTALL_DIR}/tuist\""
|
||||
sudo_if_install_dir_not_writeable "chmod +x \"${INSTALL_DIR}/tuist\""
|
||||
|
||||
rm -rf /tmp/tuistenv
|
||||
rm /tmp/tuistenv.zip
|
||||
|
|
|
@ -20,7 +20,18 @@ warn() {
|
|||
printf "${tty_red}Warning${tty_reset}: %s\n" "$(chomp "$1")"
|
||||
}
|
||||
|
||||
rm -rf /usr/local/bin/tuist
|
||||
INSTALL_DIR="/usr/local/bin"
|
||||
|
||||
sudo_if_install_dir_not_writeable() {
|
||||
local command="$1"
|
||||
if [ -w $INSTALL_DIR ]; then
|
||||
bash -c $command
|
||||
else
|
||||
bash -c "sudo ${command}"
|
||||
fi
|
||||
}
|
||||
|
||||
sudo_if_install_dir_not_writeable "rm -rf /usr/local/bin/tuist"
|
||||
rm -rf ~/.tuist
|
||||
|
||||
ohai "Tuist uninstalled"
|
||||
|
|
Loading…
Reference in New Issue