Skip to content

Commit

Permalink
fix Fixed install,uninstaller bug
Browse files Browse the repository at this point in the history
  • Loading branch information
aifirstd3v committed Jun 19, 2024
1 parent 90a6fd6 commit 9ff21dd
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 19 deletions.
21 changes: 15 additions & 6 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,28 @@ add_to_path() {
SHELL_CONFIG="$HOME/.zshrc"
;;
*)
fmt_error "Unsupported shell: $SHELL_NAME. Please add /usr/local/bin to your PATH manually."
fmt_error "Unsupported shell: $SHELL_NAME. Please add $INSTALL_DIR and /usr/local/bin to your PATH manually."
exit 1
;;
esac

if ! grep -q 'create-poetry-app' "$SHELL_CONFIG"; then
echo "Adding create-poetry-app to your PATH in $SHELL_CONFIG..."
# Add INSTALL_DIR to PATH if not already present
if ! grep -q "$INSTALL_DIR" "$SHELL_CONFIG"; then
echo "Adding $INSTALL_DIR to your PATH in $SHELL_CONFIG..."
echo "export PATH=\"$INSTALL_DIR:\$PATH\"" >> "$SHELL_CONFIG"
else
echo "$INSTALL_DIR is already in your PATH."
fi

# Add /usr/local/bin to PATH if not already present
if ! grep -q '/usr/local/bin' "$SHELL_CONFIG"; then
echo "Adding /usr/local/bin to your PATH in $SHELL_CONFIG..."
echo 'export PATH="/usr/local/bin:$PATH"' >> "$SHELL_CONFIG"
source "$SHELL_CONFIG"
else
echo "create-poetry-app is already in your PATH."
echo "/usr/local/bin is already in your PATH."
fi

source "$SHELL_CONFIG"
}

# Function to check and install necessary dependencies
Expand Down Expand Up @@ -139,7 +149,6 @@ install_python_dependencies() {
fi
}


# Main function to install create-poetry-app
main() {
# Display information
Expand Down
38 changes: 25 additions & 13 deletions uninstaller.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
# env command to find sh in the user's PATH, making it more portable across different Unix-like systems.
#!/usr/bin/env sh

# makes the script exit immediately if any command returns a non-zero exit status. This is useful for:
# Preventing the script from continuing when an error occurs.
# Ensuring that any error is caught and handled appropriately.
# Makes the script exit immediately if any command returns a non-zero exit status.
set -e



# Function to display information about the script
display_info() {
echo "⚠️ Welcome to the create-poetry-app Uninstaller!"
Expand All @@ -33,24 +28,30 @@ fmt_error() {
confirm_uninstallation() {
read -r -p "Are you sure you want to remove create-poetry-app? [y/N] " confirmation
if [ "$confirmation" != y ] && [ "$confirmation" != Y ]; then
echo "Uninstall cancelled"
echo "Uninstall cancelled."
exit
fi
}

# Function to remove installation directory
remove_installation_directory() {
echo "Removing ~/.create-poetry-app"
if [ -d "$HOME/.create-poetry-app" ]; then
echo "Removing $HOME/.create-poetry-app..."
rm -rf "$HOME/.create-poetry-app"
echo "Installation directory removed."
else
echo "$HOME/.create-poetry-app does not exist. Skipping."
fi
}

# Function to remove symbolic link
remove_symbolic_link() {
if [ -L /usr/local/bin/create-poetry-app ]; then
echo "Removing /usr/local/bin/create-poetry-app"
echo "Removing /usr/local/bin/create-poetry-app..."
sudo rm -f /usr/local/bin/create-poetry-app
echo "Symbolic link removed."
else
echo "/usr/local/bin/create-poetry-app does not exist. Skipping."
fi
}

Expand All @@ -73,9 +74,20 @@ determine_shell_config() {

# Function to remove the create-poetry-app PATH modification from the shell configuration file
remove_path_modification() {
echo "Removing create-poetry-app from your PATH in $SHELL_CONFIG..."
sed -i.bak '/export PATH="\$HOME\/.create-poetry-app:\$PATH"/d' "$SHELL_CONFIG"
source "$SHELL_CONFIG"
if [ -f "$SHELL_CONFIG" ]; then
echo "Removing create-poetry-app from your PATH in $SHELL_CONFIG..."
sed -i.bak "\|export PATH=\"$HOME/.create-poetry-app:\$PATH\"|d" "$SHELL_CONFIG"
echo "PATH modification removed."
echo "A backup of your original shell configuration file has been created: $SHELL_CONFIG.bak"
# Reload shell configuration
if [ -n "$BASH_SOURCE" ]; then
source "$SHELL_CONFIG"
else
. "$SHELL_CONFIG"
fi
else
fmt_error "$SHELL_CONFIG not found. Please manually remove the create-poetry-app path from your PATH."
fi
}

# Main function to uninstall create-poetry-app
Expand Down Expand Up @@ -104,4 +116,4 @@ main() {
}

# Run the main function
main
main

0 comments on commit 9ff21dd

Please sign in to comment.