-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbrew.bash
50 lines (43 loc) · 971 Bytes
/
brew.bash
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/env bash
import brew_portable
import log
import exec
brew::is_installed() {
local pkg=$1
if brew::brew list "$1" &>/dev/null;then
return 0
fi
return 1
}
brew::install() {
local pkg=$1
log::info "Installing $pkg..."
exec::exec_preview brew::brew install "$pkg"
}
brew::upgrade() {
local pkg=$1
log::info "Upgrading $pkg..."
exec::exec_preview brew::brew upgrade "$pkg"
}
brew::reinstall() {
local pkg=$1
log::info "Reinstalling $pkg..."
exec::exec_preview brew::brew reinstall "$pkg"
}
brew::upgrade_all() {
log::info "Upgrading packages..."
exec::exec_preview brew::brew upgrade
}
# $1 pkg name
# $2 (optional) binary name for quick instalation check
brew::require() {
local pkg=$1
local binary=${2:-$1}
brew::_assert_env
if [ -f "$BASHLIB_BREW_DIR/bin/$binary" ];then
return
fi
if ! brew::is_installed "$pkg";then
brew::install "$pkg"
fi
}