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
6f3230b3
Commit
6f3230b3
authored
Aug 13, 2015
by
Samuel E. Giddins
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Executable] Add capture_command method
parent
0d44a527
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
43 additions
and
18 deletions
+43
-18
downloader.rb
lib/cocoapods/downloader.rb
+1
-1
executable.rb
lib/cocoapods/executable.rb
+40
-16
file_accessor.rb
lib/cocoapods/sandbox/file_accessor.rb
+2
-1
No files found.
lib/cocoapods/downloader.rb
View file @
6f3230b3
...
...
@@ -125,7 +125,7 @@ module Pod
class
Base
override_api
do
def
execute_command
(
executable
,
command
,
raise_on_failure
=
false
)
Executable
.
execute_command
(
executable
,
command
,
raise_on_failure
,
:message
=>
true
)
Executable
.
execute_command
(
executable
,
command
,
raise_on_failure
)
rescue
CLAide
::
InformativeError
=>
e
raise
DownloaderError
,
e
.
message
end
...
...
lib/cocoapods/executable.rb
View file @
6f3230b3
...
...
@@ -20,15 +20,11 @@ module Pod
#
def
executable
(
name
)
define_method
(
name
)
do
|*
command
|
Executable
.
execute_command
(
name
,
Array
(
command
).
flatten
,
false
,
:message
=>
true
)
Executable
.
execute_command
(
name
,
Array
(
command
).
flatten
,
false
)
end
define_method
(
name
.
to_s
+
'!'
)
do
|*
command
|
Executable
.
execute_command
(
name
,
Array
(
command
).
flatten
,
true
,
:message
=>
true
)
end
define_method
(
name
.
to_s
+
'?'
)
do
|*
command
|
Executable
.
execute_command
(
name
,
Array
(
command
).
flatten
,
false
)
Executable
.
execute_command
(
name
,
Array
(
command
).
flatten
,
true
)
end
end
...
...
@@ -49,14 +45,14 @@ module Pod
#
# @return [String] the output of the command (STDOUT and STDERR).
#
def
self
.
execute_command
(
executable
,
command
,
raise_on_failure
=
true
,
message:
false
,
output: :both
)
def
self
.
execute_command
(
executable
,
command
,
raise_on_failure
=
true
)
bin
=
which
(
executable
)
raise
Informative
,
"Unable to locate the executable `
#{
executable
}
`"
if
bin
.
empty?
raise
Informative
,
"Unable to locate the executable `
#{
executable
}
`"
unless
bin
command
=
command
.
map
(
&
:to_s
)
full_command
=
"
#{
bin
}
#{
command
.
join
(
' '
)
}
"
if
message
&&
Config
.
instance
.
verbose?
if
Config
.
instance
.
verbose?
UI
.
message
(
"$
#{
full_command
}
"
)
stdout
,
stderr
=
Indenter
.
new
(
STDOUT
),
Indenter
.
new
(
STDERR
)
else
...
...
@@ -65,19 +61,16 @@ module Pod
status
=
popen3
(
bin
,
command
,
stdout
,
stderr
)
stdout
,
stderr
=
stdout
.
join
,
stderr
.
join
output
=
stdout
+
stderr
unless
status
.
success?
if
raise_on_failure
raise
Informative
,
"
#{
full_command
}
\n\n
#{
stdout
+
stderr
}
"
els
if
message
raise
Informative
,
"
#{
full_command
}
\n\n
#{
output
}
"
els
e
message
UI
.
message
(
"[!] Failed:
#{
full_command
}
"
.
red
)
end
end
case
output
when
:stdout
then
stdout
when
:stderr
then
stderr
else
stdout
+
stderr
end
output
end
# Returns the absolute path to the binary with the given name on the current
...
...
@@ -100,6 +93,37 @@ module Pod
nil
end
# Runs the given command, capturing the desired output.
#
# @param [String] bin
# The binary to use.
#
# @param [Array<#to_s>] command
# The command to send to the binary.
#
# @param [Symbol] capture
# Whether it should raise if the command fails.
#
# @raise If the executable could not be located.
#
# @return [(String, Process::Status)]
# The desired captured output from the command, and the status from
# running the command.
#
def
capture_command
(
executable
,
command
,
capture: :merge
)
bin
=
which
(
executable
)
raise
Informative
,
"Unable to locate the executable `
#{
executable
}
`"
unless
bin
require
'open3'
case
capture
when
:merge
then
Open3
.
capture2e
(
bin
,
*
command
)
when
:both
then
Open3
.
capture3
(
bin
,
*
command
)
when
:out
then
Open3
.
capture2
(
bin
,
*
command
)
when
:err
then
Open3
.
capture3
(
bin
,
*
command
).
drop
(
1
)
when
:none
then
Open3
.
capture2
(
bin
,
*
command
).
last
end
end
private
def
self
.
popen3
(
bin
,
command
,
stdout
,
stderr
)
...
...
lib/cocoapods/sandbox/file_accessor.rb
View file @
6f3230b3
...
...
@@ -337,7 +337,8 @@ module Pod
def
dynamic_binary?
(
binary
)
return
unless
binary
.
file?
Executable
.
execute_command
(
'file'
,
[
binary
],
false
)
=~
/dynamically linked/
output
,
status
=
Executable
.
capture_command
(
'file'
,
[
binary
],
:capture
=>
:out
)
status
.
success?
&&
output
=~
/dynamically linked/
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