utils: make which_editor handle editor args.
Handle cases like e.g. `EDITOR="subl -w"`.
This commit is contained in:
parent
cfe2c3c900
commit
3e40059f8d
@ -191,7 +191,7 @@ describe "globally-scoped helper methods" do
|
|||||||
ENV["HOMEBREW_EDITOR"] = "vemate"
|
ENV["HOMEBREW_EDITOR"] = "vemate"
|
||||||
ENV["HOMEBREW_PATH"] = dir
|
ENV["HOMEBREW_PATH"] = dir
|
||||||
|
|
||||||
editor = dir/"vemate"
|
editor = "#{dir}/vemate"
|
||||||
FileUtils.touch editor
|
FileUtils.touch editor
|
||||||
FileUtils.chmod 0755, editor
|
FileUtils.chmod 0755, editor
|
||||||
|
|
||||||
|
|||||||
@ -321,7 +321,16 @@ end
|
|||||||
|
|
||||||
def which_editor
|
def which_editor
|
||||||
editor = ENV.values_at("HOMEBREW_EDITOR", "VISUAL").compact.reject(&:empty?).first
|
editor = ENV.values_at("HOMEBREW_EDITOR", "VISUAL").compact.reject(&:empty?).first
|
||||||
return which(editor, ENV["HOMEBREW_PATH"]) unless editor.nil?
|
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
|
||||||
|
end
|
||||||
|
|
||||||
# Find Textmate
|
# Find Textmate
|
||||||
editor = which("mate", ENV["HOMEBREW_PATH"])
|
editor = which("mate", ENV["HOMEBREW_PATH"])
|
||||||
@ -338,7 +347,7 @@ def which_editor
|
|||||||
or HOMEBREW_EDITOR to your preferred text editor.
|
or HOMEBREW_EDITOR to your preferred text editor.
|
||||||
EOS
|
EOS
|
||||||
|
|
||||||
editor
|
editor.to_s
|
||||||
end
|
end
|
||||||
|
|
||||||
def exec_editor(*args)
|
def exec_editor(*args)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user