cmd/edit: stop double warning

When you don't have EDITOR or HOMEBREW_EDITOR
configured `brew edit` printed a double warning.

This silences the first of those.
This commit is contained in:
apainintheneck 2023-02-11 00:16:11 -08:00
parent 5cfb179831
commit a7dbd738dd
2 changed files with 9 additions and 7 deletions

View File

@ -45,7 +45,7 @@ module Homebrew
paths = if args.named.empty? paths = if args.named.empty?
# Sublime requires opting into the project editing path, # Sublime requires opting into the project editing path,
# as opposed to VS Code which will infer from the .vscode path # as opposed to VS Code which will infer from the .vscode path
if which_editor == "subl" if which_editor(silent: true) == "subl"
["--project", "#{HOMEBREW_REPOSITORY}/.sublime/homebrew.sublime-project"] ["--project", "#{HOMEBREW_REPOSITORY}/.sublime/homebrew.sublime-project"]
else else
# If no formulae are listed, open the project root in an editor. # If no formulae are listed, open the project root in an editor.

View File

@ -361,7 +361,7 @@ module Kernel
end.compact.uniq end.compact.uniq
end end
def which_editor def which_editor(silent: false)
editor = Homebrew::EnvConfig.editor editor = Homebrew::EnvConfig.editor
return editor if editor return editor if editor
@ -371,11 +371,13 @@ module Kernel
end end
editor ||= "vim" editor ||= "vim"
opoo <<~EOS unless silent
Using #{editor} because no editor was set in the environment. opoo <<~EOS
This may change in the future, so we recommend setting EDITOR, Using #{editor} because no editor was set in the environment.
or HOMEBREW_EDITOR to your preferred text editor. This may change in the future, so we recommend setting EDITOR,
EOS or HOMEBREW_EDITOR to your preferred text editor.
EOS
end
editor editor
end end