Skip to content

Commit 4c62605

Browse files
authored
❇️ refactor: macos-brew (#57)
- Move package under `/pkg` (See #40) - Consolidate command steps to the install script - Disable folding so it's easier to add aliases in the future
2 parents 6b207b4 + 77d16d5 commit 4c62605

15 files changed

Lines changed: 31 additions & 13 deletions

File tree

makefiles/macos.mk

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,7 @@
55
macos-core: macos-brew macos-stow macos-zsh
66

77
macos-brew:
8-
$(eval BREW_BIN := $(shell bin/brew_bin))
9-
exists brew || xscript "scripts/macos-brew.sh"
10-
${BREW_BIN}/brew bundle --file brewfiles/core.Brewfile
11-
${BREW_BIN}/stow --no-folding --target "${HOME}" macos-brew
12-
@if ${BREW_BIN}/brew autoupdate status | grep -q "stopped"; then \
13-
${BREW_BIN}/brew autoupdate start; \
14-
fi
8+
xscript "pkg/brew/macos-brew.sh"
159

1610
macos-clean:
1711
find . -name ".DS_Store" -delete

pkg/brew/macos-brew.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/bin/bash
2+
set -euo pipefail
3+
4+
BREW_BIN="$(bin/brew_bin)"
5+
6+
# Install Homebrew
7+
# Reference: https://brew.sh/
8+
if ! command -v brew &>/dev/null; then
9+
echo "🍺 Installing Homebrew"
10+
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
11+
else
12+
echo "🍺 Homebrew is already installed"
13+
fi
14+
15+
# Install core packages
16+
echo "🍺 Installing Homebrew packages"
17+
"${BREW_BIN}/brew" bundle --file pkg/brew/brew.Brewfile
18+
19+
# Install aliases
20+
# Do folding here to sync new aliases back to dotfiles
21+
echo "🍺 Stowing Homebrew aliases"
22+
"${BREW_BIN}/stow" --dir 'pkg/brew' --target "${HOME}" 'stow'
23+
24+
# Start autoupdate service
25+
if "${BREW_BIN}/brew" autoupdate status | grep -q 'stopped'; then
26+
echo "🍺 Starting Homebrew autoupdate service"
27+
"${BREW_BIN}/brew" autoupdate start
28+
else
29+
echo "🍺 Homebrew autoupdate service is already running"
30+
fi

0 commit comments

Comments
 (0)