Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dev-cmd/edit: simplify project view handling. #4843

Merged
merged 1 commit into from
Sep 6, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
35 changes: 7 additions & 28 deletions Library/Homebrew/dev-cmd/edit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,36 +26,15 @@ def edit
end

# If no brews are listed, open the project root in an editor.
if ARGV.named.empty?
editor = File.basename which_editor
if ["atom", "subl", "mate"].include?(editor)
# If the user is using Atom, Sublime Text or TextMate
# give a nice project view instead.
exec_editor HOMEBREW_REPOSITORY/"bin/brew",
HOMEBREW_REPOSITORY/"README.md",
HOMEBREW_REPOSITORY/".gitignore",
*library_folders
else
exec_editor HOMEBREW_REPOSITORY
end
else
# Don't use ARGV.formulae as that will throw if the file doesn't parse
paths = ARGV.named.map do |name|
path = Formulary.path(name)
paths = [HOMEBREW_REPOSITORY] if ARGV.named.empty?

raise FormulaUnavailableError, name unless path.file? || args.force?

path
end
exec_editor(*paths)
# Don't use ARGV.formulae as that will throw if the file doesn't parse
paths ||= ARGV.named.map do |name|
path = Formulary.path(name)
raise FormulaUnavailableError, name if !path.file? && !args.force?
path
end
end

def library_folders
Dir["#{HOMEBREW_LIBRARY}/*"].reject do |d|
case File.basename(d)
when "LinkedKegs", "Aliases" then true
end
end
exec_editor(*paths)
end
end