don't try to find the full path of the editor in 'brew edit'

fixes #2709
This commit is contained in:
adrian 2017-06-01 17:45:07 -07:00
parent 8b26deef20
commit de78999def
2 changed files with 17 additions and 19 deletions

View File

@ -188,14 +188,14 @@ describe "globally-scoped helper methods" do
end
specify "#which_editor" do
ENV["HOMEBREW_EDITOR"] = "vemate"
ENV["HOMEBREW_EDITOR"] = "vemate -w"
ENV["HOMEBREW_PATH"] = dir
editor = "#{dir}/vemate"
FileUtils.touch editor
FileUtils.chmod 0755, editor
expect(which_editor).to eql editor
expect(which_editor).to eq("vemate -w")
end
specify "#gzip" do

View File

@ -262,6 +262,14 @@ ensure
ENV["PATH"] = old_path
end
def with_homebrew_path
old_path = ENV["PATH"]
ENV["PATH"] = ENV["HOMEBREW_PATH"]
yield
ensure
ENV["PATH"] = old_path
end
def with_custom_locale(locale)
old_locale = ENV["LC_ALL"]
ENV["LC_ALL"] = locale
@ -321,23 +329,13 @@ end
def which_editor
editor = ENV.values_at("HOMEBREW_EDITOR", "HOMEBREW_VISUAL").compact.reject(&:empty?).first
if editor
editor_name, _, editor_args = editor.partition " "
editor_path = which(editor_name, ENV["HOMEBREW_PATH"])
editor = if editor_args.to_s.empty?
editor_path.to_s
else
"#{editor_path} #{editor_args}"
end
return editor
return editor unless editor.nil?
# Find Textmate, BBEdit / TextWrangler, or vim
%w[mate edit vim].each do |candidate|
editor = candidate if which(candidate, ENV["HOMEBREW_PATH"])
end
# Find Textmate
editor = which("mate", ENV["HOMEBREW_PATH"])
# Find BBEdit / TextWrangler
editor ||= which("edit", ENV["HOMEBREW_PATH"])
# Find vim
editor ||= which("vim", ENV["HOMEBREW_PATH"])
# Default to standard vim
editor ||= "/usr/bin/vim"
@ -347,12 +345,12 @@ def which_editor
or HOMEBREW_EDITOR to your preferred text editor.
EOS
editor.to_s
editor
end
def exec_editor(*args)
puts "Editing #{args.join "\n"}"
safe_exec(which_editor, *args)
with_homebrew_path { safe_exec(which_editor, *args) }
end
def exec_browser(*args)