mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00

Return `opt_prefix` if it exists and `prefix` is not called from within the same formula's `install` or `post_install` methods. Otherwise, fall back to the existing functionality. This avoids the need to use `opt_prefix` etc. everywhere and generally means we don't expose an implementation detail (i.e. the full Cellar path) to dependents that have a habit of hard-coding it.
18 lines
383 B
Ruby
18 lines
383 B
Ruby
#: * `--prefix`:
|
|
#: Display Homebrew's install path. *Default:* `/usr/local`
|
|
#:
|
|
#: * `--prefix` <formula>:
|
|
#: Display the location in the cellar where <formula> is or would be installed.
|
|
|
|
module Homebrew
|
|
module_function
|
|
|
|
def __prefix
|
|
if ARGV.named.empty?
|
|
puts HOMEBREW_PREFIX
|
|
else
|
|
puts ARGV.resolved_formulae.map(&:installed_prefix)
|
|
end
|
|
end
|
|
end
|