brew/Library/Homebrew/cmd/--prefix.rb
Mike McQuaid a571965df9 formula: make prefix usually return opt_prefix.
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.
2016-12-31 16:38:05 +00:00

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