homebrew-cask/ci/travis/helpers.sh

46 lines
816 B
Bash
Raw Normal View History

#!/usr/bin/env bash
#
# helpers.sh
#
# Helper functions for Travis build scripts.
#
# force strict error checking
set -o errexit
set -o pipefail
# enable extended globbing syntax
shopt -s extglob
CYAN='\033[0;36m'
MAGENTA='\033[1;35m'
NC='\033[0m' # no color
# log command before running and add a blank line
run () {
echo -e "${MAGENTA}>>>${NC} $*"
eval "$*"
local retval=$?
echo
return $retval
}
# print args as a cyan header
header () {
echo
echo -e "${CYAN}$*${NC}"
echo
}
2016-01-08 22:05:31 +08:00
modified_cask_files () {
if [[ -z "${MODIFIED_CASK_FILES+defined}" ]]; then
MODIFIED_CASK_FILES="$(git diff --name-only --diff-filter=AM "${TRAVIS_COMMIT_RANGE}" -- Casks/*.rb)"
2016-01-08 22:05:31 +08:00
export MODIFIED_CASK_FILES
fi
echo "${MODIFIED_CASK_FILES}"
}
any_casks_modified () {
[[ -n "$(modified_cask_files)" ]]
}