Replace ENV["HOME"] with Dir.home
This commit is contained in:
parent
40bbdc659e
commit
e78665f4f7
@ -106,7 +106,7 @@ module Cask
|
|||||||
+"/Library/LaunchAgents/#{service}.plist",
|
+"/Library/LaunchAgents/#{service}.plist",
|
||||||
+"/Library/LaunchDaemons/#{service}.plist",
|
+"/Library/LaunchDaemons/#{service}.plist",
|
||||||
]
|
]
|
||||||
paths.each { |elt| elt.prepend(ENV["HOME"]).freeze } unless with_sudo
|
paths.each { |elt| elt.prepend(Dir.home).freeze } unless with_sudo
|
||||||
paths = paths.map { |elt| Pathname(elt) }.select(&:exist?)
|
paths = paths.map { |elt| Pathname(elt) }.select(&:exist?)
|
||||||
paths.each do |path|
|
paths.each do |path|
|
||||||
command.run!("/bin/rm", args: ["-f", "--", path], sudo: with_sudo)
|
command.run!("/bin/rm", args: ["-f", "--", path], sudo: with_sudo)
|
||||||
|
|||||||
@ -96,7 +96,7 @@ module Cask
|
|||||||
end
|
end
|
||||||
|
|
||||||
def printable_target
|
def printable_target
|
||||||
target.to_s.sub(/^#{ENV['HOME']}(#{File::SEPARATOR}|$)/, "~/")
|
target.to_s.sub(/^#{Dir.home}(#{File::SEPARATOR}|$)/, "~/")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -241,7 +241,7 @@ module Cask
|
|||||||
|
|
||||||
def to_h_string_gsubs(string)
|
def to_h_string_gsubs(string)
|
||||||
string.to_s
|
string.to_s
|
||||||
.gsub(ENV["HOME"], "$HOME")
|
.gsub(Dir.home, "$HOME")
|
||||||
.gsub(HOMEBREW_PREFIX, "$(brew --prefix)")
|
.gsub(HOMEBREW_PREFIX, "$(brew --prefix)")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -190,7 +190,7 @@ module Cask
|
|||||||
key = "language"
|
key = "language"
|
||||||
value = T.cast(explicit.fetch(:languages, []), T::Array[String]).join(",")
|
value = T.cast(explicit.fetch(:languages, []), T::Array[String]).join(",")
|
||||||
end
|
end
|
||||||
"#{key}: \"#{value.to_s.sub(/^#{ENV['HOME']}/, "~")}\""
|
"#{key}: \"#{value.to_s.sub(/^#{Dir.home}/, "~")}\""
|
||||||
end.join(", ")
|
end.join(", ")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -70,7 +70,7 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
|
|
||||||
def user_tilde(path)
|
def user_tilde(path)
|
||||||
path.gsub(ENV["HOME"], "~")
|
path.gsub(Dir.home, "~")
|
||||||
end
|
end
|
||||||
|
|
||||||
sig { returns(String) }
|
sig { returns(String) }
|
||||||
@ -766,7 +766,7 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
|
|
||||||
def check_for_pydistutils_cfg_in_home
|
def check_for_pydistutils_cfg_in_home
|
||||||
return unless File.exist? "#{ENV["HOME"]}/.pydistutils.cfg"
|
return unless File.exist? "#{Dir.home}/.pydistutils.cfg"
|
||||||
|
|
||||||
<<~EOS
|
<<~EOS
|
||||||
A '.pydistutils.cfg' file was found in $HOME, which may cause Python
|
A '.pydistutils.cfg' file was found in $HOME, which may cause Python
|
||||||
|
|||||||
@ -2433,7 +2433,7 @@ class Formula
|
|||||||
GOCACHE: "#{HOMEBREW_CACHE}/go_cache",
|
GOCACHE: "#{HOMEBREW_CACHE}/go_cache",
|
||||||
GOPATH: "#{HOMEBREW_CACHE}/go_mod_cache",
|
GOPATH: "#{HOMEBREW_CACHE}/go_mod_cache",
|
||||||
CARGO_HOME: "#{HOMEBREW_CACHE}/cargo_cache",
|
CARGO_HOME: "#{HOMEBREW_CACHE}/cargo_cache",
|
||||||
CURL_HOME: ENV["CURL_HOME"] || ENV["HOME"],
|
CURL_HOME: ENV.fetch("CURL_HOME") { Dir.home },
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -904,7 +904,7 @@ class FormulaInstaller
|
|||||||
sandbox = Sandbox.new
|
sandbox = Sandbox.new
|
||||||
formula.logs.mkpath
|
formula.logs.mkpath
|
||||||
sandbox.record_log(formula.logs/"build.sandbox.log")
|
sandbox.record_log(formula.logs/"build.sandbox.log")
|
||||||
sandbox.allow_write_path(ENV["HOME"]) if interactive?
|
sandbox.allow_write_path(Dir.home) if interactive?
|
||||||
sandbox.allow_write_temp_and_cache
|
sandbox.allow_write_temp_and_cache
|
||||||
sandbox.allow_write_log(formula)
|
sandbox.allow_write_log(formula)
|
||||||
sandbox.allow_cvs
|
sandbox.allow_cvs
|
||||||
|
|||||||
@ -8,9 +8,9 @@ cask "with-uninstall-script-user-relative" do
|
|||||||
app "MyFancyApp/MyFancyApp.app", target: "~/MyFancyApp.app"
|
app "MyFancyApp/MyFancyApp.app", target: "~/MyFancyApp.app"
|
||||||
|
|
||||||
postflight do
|
postflight do
|
||||||
File.write "#{ENV["HOME"]}/MyFancyApp.app/uninstall.sh", <<~SH
|
File.write "#{Dir.home}/MyFancyApp.app/uninstall.sh", <<~SH
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
/bin/rm -r "#{ENV["HOME"]}/MyFancyApp.app"
|
/bin/rm -r "#{Dir.home}/MyFancyApp.app"
|
||||||
SH
|
SH
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -291,7 +291,7 @@ module Kernel
|
|||||||
ENV["HOMEBREW_DEBUG_INSTALL"] = f.full_name
|
ENV["HOMEBREW_DEBUG_INSTALL"] = f.full_name
|
||||||
end
|
end
|
||||||
|
|
||||||
if ENV["SHELL"].include?("zsh") && (home = ENV["HOME"])&.start_with?(HOMEBREW_TEMP.resolved_path.to_s)
|
if ENV["SHELL"].include?("zsh") && (home = Dir.home).start_with?(HOMEBREW_TEMP.resolved_path.to_s)
|
||||||
FileUtils.mkdir_p home
|
FileUtils.mkdir_p home
|
||||||
FileUtils.touch "#{home}/.zshrc"
|
FileUtils.touch "#{home}/.zshrc"
|
||||||
end
|
end
|
||||||
|
|||||||
@ -49,7 +49,7 @@ module Utils
|
|||||||
def profile
|
def profile
|
||||||
case preferred
|
case preferred
|
||||||
when :bash
|
when :bash
|
||||||
bash_profile = "#{ENV["HOME"]}/.bash_profile"
|
bash_profile = "#{Dir.home}/.bash_profile"
|
||||||
return bash_profile if File.exist? bash_profile
|
return bash_profile if File.exist? bash_profile
|
||||||
when :zsh
|
when :zsh
|
||||||
return "#{ENV["ZDOTDIR"]}/.zshrc" if ENV["ZDOTDIR"].present?
|
return "#{ENV["ZDOTDIR"]}/.zshrc" if ENV["ZDOTDIR"].present?
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user