Skip to content
This repository has been archived by the owner on Aug 27, 2024. It is now read-only.

Commit

Permalink
support homebrew
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewhadley committed Jun 30, 2015
1 parent 03ba55b commit 73220af
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# 0.1.0
- add support for homebrew

# 0.0.9
- fix testing for existing groups in user type

Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ Currently supported types are:
assert package installed via apt-get on Debian or Ubuntu linux
> apt package
* brew
assert package installed via homebrew on OSX
> brew package
* dir
assert presence of a directory
> dir /tmp/foo
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.0.9
0.1.0
5 changes: 5 additions & 0 deletions test/helpers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ skip_linux() {
return 0
}

skip_darwin() {
[ "$platform" != "Darwin" ] && skip "requires OSX"
return 0
}

skip_exec() {
exec "$1"
[ $? -ne 0 ] && skip "requires $1"
Expand Down
26 changes: 26 additions & 0 deletions test/type-brew.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env bats

. test/helpers.sh

fn() { . $BOLT_DIR/types/brew.sh $*; }

@test "brew status: returns MISSING if package is not present" {
skip_darwin && skip_exec brew
run fn status doesnotexist
[ $status -eq $STATUS_MISSING ]
}

@test "brew install: installs the package" {
skip_darwin && skip_exec brew
brew remove hr
run fn install hr
[ $status -eq $STATUS_OK ]
which hr
[ $status -eq $STATUS_OK ]
}

@test "brew status: returns OK if package is present" {
skip_darwin && skip_exec brew
run fn status hr
[ $status -eq $STATUS_OK ]
}
34 changes: 34 additions & 0 deletions types/brew.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# modified from original version at https://github.com/mattly/bork

action=$1
name=$2
shift 2

case $action in
desc)
echo "assert package installed via homebrew on OSX"
echo "> brew package"
;;

status)
platform "Darwin" || return "$STATUS_UNSUPPORTED_PLATFORM"
exec "ruby" || return "$STATUS_FAILED_PRECONDITION"

echo "$(brew list)" | grep "^$name"
[ "$?" -gt 0 ] && return "$STATUS_MISSING"

brew outdated $name
[ "$?" -ne 0 ] && return "$STATUS_OUTDATED"
return "$STATUS_OK"
;;

install)
brew install $name
;;

upgrade)
brew upgrade $name
;;

*) return 1 ;;
esac

0 comments on commit 73220af

Please sign in to comment.