Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
C
cocoapods
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gengmeiios
cocoapods
Commits
2c0f2386
Commit
2c0f2386
authored
Nov 27, 2015
by
Samuel Giddins
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Spec::Edit] Use Executable.which
parent
e547edd6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
21 deletions
+12
-21
edit.rb
lib/cocoapods/command/spec/edit.rb
+12
-21
No files found.
lib/cocoapods/command/spec/edit.rb
View file @
2c0f2386
...
...
@@ -48,32 +48,23 @@ module Pod
raise
Informative
,
"
#{
filepath
}
doesn't exist."
end
# Looks up an executable in the search paths
#
# @note
# Thank you homebrew
#
# @param [String] cmd
# the executable to look up
#
def
which
(
cmd
)
dir
=
ENV
[
'PATH'
].
split
(
':'
).
find
{
|
p
|
File
.
executable?
File
.
join
(
p
,
cmd
)
}
Pathname
.
new
(
File
.
join
(
dir
,
cmd
))
unless
dir
.
nil?
end
def
which_editor
editor
=
ENV
[
'EDITOR'
]
# If an editor wasn't set, try to pick a sane default
return
editor
unless
editor
.
nil?
# Find Sublime Text 2
return
'subl'
if
which
'subl'
# Find Textmate
return
'mate'
if
which
'mate'
# Find # BBEdit / TextWrangler
return
'edit'
if
which
'edit'
# Default to vim
return
'vim'
if
which
'vim'
editors
=
[
# Find Sublime Text 2
'subl'
,
# Find Textmate
'mate'
,
# Find # BBEdit / TextWrangler
'edit'
,
# Default to vim
'vim'
,
]
editor
=
editors
.
find
{
|
e
|
Pod
::
Executable
.
which
(
e
)
}
return
editor
if
editor
raise
Informative
,
"Failed to open editor. Set your 'EDITOR' environment variable."
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment