edit: enable Sublime Text project view

This commit is contained in:
Misty De Meo 2021-04-02 15:36:29 -07:00
parent bdc3391a13
commit 04c8e896a5
No known key found for this signature in database
GPG Key ID: 76CF846A2F674B2C
3 changed files with 48 additions and 10 deletions

4
.gitignore vendored
View File

@ -194,5 +194,7 @@
# Unignore tests' bundle config
!/Library/Homebrew/test/.bundle/config
# Unignore vscode configuration
# Unignore editor configuration
!/.sublime
/.sublime/homebrew.sublime-workspace
!/.vscode

View File

@ -0,0 +1,28 @@
{
"folders":
[
{
"//": "Generated based on the contents of our .gitignore",
"path": "..",
"folder_exclude_patterns": [
"Caskroom",
"Cellar",
"Frameworks",
"bin",
"etc",
"include",
"lib",
"opt",
"sbin",
"share",
"var",
"Library/Homebrew/LinkedKegs",
"Library/Homebrew/Aliases"
],
"follow_symlinks": true
}
],
"settings": {
"tab_size": 2
}
}

View File

@ -40,16 +40,24 @@ module Homebrew
EOS
end
paths = args.named.to_paths.select do |path|
next path if path.exist?
paths = if args.named.empty?
# Sublime requires opting into the project editing path,
# as opposed to VS Code which will infer from the .vscode path
if which_editor == "subl"
["--project", "#{HOMEBREW_REPOSITORY}/.sublime/homebrew.sublime-project"]
else
# If no formulae are listed, open the project root in an editor.
[HOMEBREW_REPOSITORY]
end
else
args.named.to_paths.select do |path|
next path if path.exist?
raise UsageError, "#{path} doesn't exist on disk. " \
"Run #{Formatter.identifier("brew create --set-name #{path.basename} $URL")} " \
"to create a new formula!"
end.presence
# If no formulae are listed, open the project root in an editor.
paths ||= [HOMEBREW_REPOSITORY]
raise UsageError, "#{path} doesn't exist on disk. " \
"Run #{Formatter.identifier("brew create --set-name #{path.basename} $URL")} " \
"to create a new formula!"
end.presence
end
exec_editor(*paths)
end