Skip to content

Commit

Permalink
add force flag
Browse files Browse the repository at this point in the history
  • Loading branch information
JY8752 committed Jul 14, 2023
1 parent bb360c8 commit 586349c
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ jobs:

# Initialize and place dotfiles
- name: Setup Dotfiles
run: make
run: make test
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Do everything.
all: init link defaults brew code asdf

# Test
test: init link defaults fbrew codeex code chromeex asdf

# Set initial preference.
init:
@scripts/init.sh
Expand All @@ -17,6 +20,9 @@ defaults:
brew:
@scripts/brew.sh

fbrew:
@scripts/brew.sh --force

# update vscode extentions
codeex:
@code --list-extensions > vscode/extensions
Expand Down
2 changes: 2 additions & 0 deletions scripts/.Brewfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ tap "homebrew/cask"
tap "homebrew/cask-versions"
tap "homebrew/core"
tap "aws/tap"
tap "weaveworks/tap"
tap "kreuzwerker/taps"

brew "act"
brew "age"
Expand Down
23 changes: 23 additions & 0 deletions scripts/brew.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,31 @@ source $(dirname "${BASH_SOURCE[0]:-$0}")/util.sh

function set_homebrew() {
check_macos
check_command "brew"

print_info "Installing Homebrew packages..."

brew doctor
brew update
brew upgrade

local force=false
while [ "$#" -gt 0 ]; do
case "$1" in
--force)
force=true
;;
*)
;;
esac
shift
done

current_dir=$(dirname "${BASH_SOURCE[0]:-$0}")
if [ "$force" = true ]; then
brew bundle --file "$current_dir/.Brewfile" --force
return
fi
brew bundle --file "$current_dir/.Brewfile"
}

Expand Down
7 changes: 7 additions & 0 deletions scripts/util.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ function check_macos() {
fi
}

function check_command() {
if ! command -v "$1" >/dev/null 2>&1; then
print_error "$1 command not found!"
exit 1
fi
}

function backup_and_link() {
local link_src_file=$1
local link_dest_dir=$2
Expand Down

0 comments on commit 586349c

Please sign in to comment.