formula: add new methods
* `Formula#linked?` returns true if formula linked * `Formula#optlinked?` returns true if formula linked to opt formula installed to the Cellar * `Formula#prefix_linked?` returns true if linked keg points to the prefix passed as an argument * `Formula#linked_version` to get linked version of the formula
This commit is contained in:
parent
7b24d1d2d1
commit
52526c962b
@ -553,6 +553,28 @@ class Formula
|
|||||||
Pathname.new("#{HOMEBREW_CELLAR}/#{name}/#{v}")
|
Pathname.new("#{HOMEBREW_CELLAR}/#{name}/#{v}")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Is the formula linked?
|
||||||
|
def linked?
|
||||||
|
linked_keg.symlink?
|
||||||
|
end
|
||||||
|
|
||||||
|
# Is the formula linked to opt?
|
||||||
|
def optlinked?
|
||||||
|
opt_prefix.symlink?
|
||||||
|
end
|
||||||
|
|
||||||
|
# Is formula's linked keg points to the prefix.
|
||||||
|
def prefix_linked?(v = pkg_version)
|
||||||
|
return false unless linked?
|
||||||
|
linked_keg.resolved_path == prefix(v)
|
||||||
|
end
|
||||||
|
|
||||||
|
# {PkgVersion} of the linked keg for the formula.
|
||||||
|
def linked_version
|
||||||
|
return unless linked?
|
||||||
|
Keg.for(linked_keg).version
|
||||||
|
end
|
||||||
|
|
||||||
# The parent of the prefix; the named directory in the cellar containing all
|
# The parent of the prefix; the named directory in the cellar containing all
|
||||||
# installed versions of this software
|
# installed versions of this software
|
||||||
# @private
|
# @private
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user