Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ ones.
## Installation

- Clone this repo ```git clone https://github.com/CaptainQuirk/exx <path>```
- Add ```<path>/bin/exx``` to your __$PATH__

## Commands

Expand All @@ -15,6 +14,7 @@ ones.
- ```switch <version>```: Switch to a specified version of Xcode
- ```update```: Backs up the current Xcode.app and upgrade via __softwareupdate__
- ```reset```: Resets Xcode version to the latest
- ```install```: Install `exx` globally

## Directory Structure

Expand Down
70 changes: 70 additions & 0 deletions libexec/exx-install
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#!/usr/bin/env sh
# Usage: exx install
# Summary: Install `exx` globally

INSTALL_PATH=$HOME/.sub
COPY_DIR=$true

copy(){
CURRENT_PATH=`pwd`
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test if CURRENT_PATH is not equivalent to PATH_INSTALL

read -p "Do you wish install exx into $path ? (Y/n) : " yn

case $yn in
[Yy]*)
cp -R $CURRENT_PATH $path;
symlink;
break;;
[Nn]*) echo "non"; break;;
*) echo "Please select Y/n"
esac
}

symlink(){
BINARY_PATH="/usr/local/bin/exx"
SOURCE_PATH=$path

if [[ "$SOURCE_PATH" == */exx ]]; then
SOURCE_PATH=$(dirname $path)
fi

if [ ! \( -e "${BINARY_PATH}" \) ]; then
echo "Create symlinks into $BINARY_PATH"
ln -s $SOURCE_PATH/exx/libexec/exx $BINARY_PATH
echo "Done !"
echo "Check installation by running ``exx info`` for example"
fi
}

# test if installation path exists
# if not, we create folder
if [ ! -d $INSTALL_PATH ]; then
mkdir $INSTALL_PATH
fi

# we ask the user installation path
read -p "Path to install (default: $INSTALL_PATH) : " path

if [ -z "$path" ]; then
path=$INSTALL_PATH
fi

# if path is the current directory, don't copy
if [ "$path" == "." ]; then
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove COPY_DIR variable
Move the symlink and exit function calls up

path=`pwd`
COPY_DIR=$false
fi

if [ "$path" == `pwd` ] && [ !$COPY_DIR ]; then
symlink
exit
fi

# we check if exx exists into path
if [ ! -d "$path/exx" ]; then
copy
else
echo "exx is already install into $path"
symlink
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove else clause and call symlink everytime

fi

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Advise the user to delete the current folder if $path != "."