Merge pull request #14259 from cho-m/items-find-devnull

items.sh: return early when no Taps directory
This commit is contained in:
Mike McQuaid 2022-12-27 21:09:29 +00:00 committed by GitHub
commit b2173e6542
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 1 deletions

View File

@ -8,5 +8,17 @@
source "${HOMEBREW_LIBRARY}/Homebrew/items.sh"
homebrew-formulae() {
homebrew-items '*\.rb' 'Casks' 's|/Formula/|/|' '^homebrew/core'
local formulae
formulae="$(homebrew-items '*\.rb' 'Casks' 's|/Formula/|/|' '^homebrew/core')"
# HOMEBREW_CACHE is set by brew.sh
# shellcheck disable=SC2154
if [[ -n "${HOMEBREW_INSTALL_FROM_API}" && -f "${HOMEBREW_CACHE}/api/formula.json" ]]
then
local api_formulae
api_formulae="$(ruby -e "require 'json'; JSON.parse(File.read('${HOMEBREW_CACHE}/api/formula.json')).each { |f| puts f['name'] }" 2>/dev/null)"
formulae="$(echo -e "${formulae}\n${api_formulae}" | sort -uf | grep .)"
fi
echo "${formulae}"
}

View File

@ -17,6 +17,7 @@ homebrew-items() {
# HOMEBREW_REPOSITORY is set by brew.sh
# shellcheck disable=SC2154
[[ -d "${HOMEBREW_REPOSITORY}/Library/Taps" ]] || return
items="$(
find "${HOMEBREW_REPOSITORY}/Library/Taps" \
-type d \( \