-
Notifications
You must be signed in to change notification settings - Fork 0
feat(install): prefer Homebrew installation on macOS #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,12 +9,28 @@ command_exists() { | |
| command -v "$1" >/dev/null 2>&1 | ||
| } | ||
|
|
||
| # Flag to track whether Homebrew installation was used | ||
| BREW_INSTALLED=false | ||
|
|
||
| # Check for required commands | ||
| if ! command_exists curl; then | ||
| echo "Error: curl is not installed." | ||
| exit 1 | ||
| fi | ||
|
|
||
| # On macOS, prefer Homebrew installation if brew is available | ||
| if [[ "$OS" == "Darwin" ]] && command_exists brew; then | ||
| echo "Homebrew detected on macOS. Attempting to install via brew..." | ||
| if brew install shelltime/tap/shelltime; then | ||
| BREW_INSTALLED=true | ||
| echo "Successfully installed shelltime via Homebrew." | ||
| else | ||
| echo "Homebrew installation failed. Falling back to manual installation..." | ||
| fi | ||
| fi | ||
|
|
||
| if [ "$BREW_INSTALLED" = false ]; then | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Wrapping the entire binary-install section in Useful? React with 👍 / 👎. |
||
|
|
||
| CLI_FILE_NAME="https://github.com/malamtime/cli/releases/latest/download/cli_" | ||
| DAEMON_FILE_NAME="${CLI_FILE_NAME}daemon_" | ||
|
|
||
|
|
@@ -127,14 +143,6 @@ if [[ "$OS" == "Darwin" ]] || [[ "$OS" == "Linux" ]]; then | |
| # mv shelltime /c/Windows/System32/ | ||
| fi | ||
|
|
||
| # Check if $HOME/.shelltime/daemon exists, create if not | ||
| if [ ! -d "$HOME/.shelltime/daemon" ]; then | ||
| mkdir -p "$HOME/.shelltime/daemon" | ||
| if [ $? -ne 0 ]; then | ||
| echo "Warning: Failed to create $HOME/.shelltime/daemon directory. Daemon functionality may be unavailable." | ||
| fi | ||
| fi | ||
|
|
||
| # Add $HOME/.shelltime/bin to user path | ||
| if [[ "$OS" == "Darwin" ]] || [[ "$OS" == "Linux" ]]; then | ||
| # For Zsh | ||
|
|
@@ -185,6 +193,15 @@ if [[ "$OS" == "MINGW64_NT" ]] || [[ "$OS" == "MSYS_NT" ]] || [[ "$OS" == "CYGWI | |
| echo "If you know where binaries should be installed on Windows, please open an issue: https://github.com/shelltime/cli" | ||
| fi | ||
|
|
||
| fi # end of manual installation block | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For manual installations, the binary is moved to |
||
|
|
||
| # Check if $HOME/.shelltime/daemon exists, create if not | ||
| if [ ! -d "$HOME/.shelltime/daemon" ]; then | ||
| mkdir -p "$HOME/.shelltime/daemon" | ||
| if [ $? -ne 0 ]; then | ||
| echo "Warning: Failed to create $HOME/.shelltime/daemon directory. Daemon functionality may be unavailable." | ||
| fi | ||
| fi | ||
|
|
||
| # STEP 2 | ||
| # insert a preexec and postexec script to user configuration, including `zsh` and `fish` | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
brew installcommand returns a non-zero exit code if the package is already installed. This triggers the fallback logic and attempts a manual installation, which can lead to duplicate installations (one via Homebrew and one in~/.shelltime/bin) and user confusion. Checking if the package is already installed prevents this unnecessary fallback.