Skip to content

Commit

Permalink
Merge pull request #14259 from cho-m/items-find-devnull
Browse files Browse the repository at this point in the history
items.sh: return early when no Taps directory
  • Loading branch information
MikeMcQuaid committed Dec 27, 2022
2 parents 080a1c3 + a0e9352 commit b2173e6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
14 changes: 13 additions & 1 deletion Library/Homebrew/cmd/formulae.sh
Expand Up @@ -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}"
}
1 change: 1 addition & 0 deletions Library/Homebrew/items.sh
Expand Up @@ -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 \( \
Expand Down

0 comments on commit b2173e6

Please sign in to comment.