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
811f7eff
Commit
811f7eff
authored
Jul 17, 2015
by
Samuel E. Giddins
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Executable] Add a safe replacement for backticks
parent
5f9e19c1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
13 deletions
+18
-13
executable.rb
lib/cocoapods/executable.rb
+18
-13
No files found.
lib/cocoapods/executable.rb
View file @
811f7eff
...
@@ -20,11 +20,15 @@ module Pod
...
@@ -20,11 +20,15 @@ module Pod
#
#
def
executable
(
name
)
def
executable
(
name
)
define_method
(
name
)
do
|*
command
|
define_method
(
name
)
do
|*
command
|
Executable
.
execute_command
(
name
,
Array
(
command
).
flatten
,
false
)
Executable
.
execute_command
(
name
,
Array
(
command
).
flatten
,
false
,
:message
=>
true
)
end
end
define_method
(
name
.
to_s
+
'!'
)
do
|*
command
|
define_method
(
name
.
to_s
+
'!'
)
do
|*
command
|
Executable
.
execute_command
(
name
,
Array
(
command
).
flatten
,
true
)
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
)
end
end
end
end
...
@@ -45,18 +49,14 @@ module Pod
...
@@ -45,18 +49,14 @@ module Pod
#
#
# @return [String] the output of the command (STDOUT and STDERR).
# @return [String] the output of the command (STDOUT and STDERR).
#
#
# @todo Find a way to display the live output of the commands.
def
self
.
execute_command
(
executable
,
command
,
raise_on_failure
=
true
,
message:
false
,
output: :both
)
#
def
self
.
execute_command
(
executable
,
command
,
raise_on_failure
)
bin
=
which
(
executable
)
bin
=
which
(
executable
)
raise
Informative
,
"Unable to locate the executable `
#{
executable
}
`"
unless
bin
raise
Informative
,
"Unable to locate the executable `
#{
executable
}
`"
if
bin
.
empty?
require
'shellwords'
command
=
command
.
map
(
&
:to_s
)
command
=
command
.
map
(
&
:to_s
)
full_command
=
"
#{
bin
}
#{
command
.
join
(
' '
)
}
"
full_command
=
"
#{
bin
}
#{
command
.
join
(
' '
)
}
"
if
Config
.
instance
.
verbose?
if
message
&&
Config
.
instance
.
verbose?
UI
.
message
(
"$
#{
full_command
}
"
)
UI
.
message
(
"$
#{
full_command
}
"
)
stdout
,
stderr
=
Indenter
.
new
(
STDOUT
),
Indenter
.
new
(
STDERR
)
stdout
,
stderr
=
Indenter
.
new
(
STDOUT
),
Indenter
.
new
(
STDERR
)
else
else
...
@@ -64,15 +64,20 @@ module Pod
...
@@ -64,15 +64,20 @@ module Pod
end
end
status
=
popen3
(
bin
,
command
,
stdout
,
stderr
)
status
=
popen3
(
bin
,
command
,
stdout
,
stderr
)
output
=
stdout
.
join
+
stderr
.
join
stdout
,
stderr
=
stdout
.
join
,
stderr
.
join
unless
status
.
success?
unless
status
.
success?
if
raise_on_failure
if
raise_on_failure
raise
Informative
,
"
#{
full_command
}
\n\n
#{
output
}
"
raise
Informative
,
"
#{
full_command
}
\n\n
#{
stdout
+
stderr
}
"
else
els
if
messag
e
UI
.
message
(
"[!] Failed:
#{
full_command
}
"
.
red
)
UI
.
message
(
"[!] Failed:
#{
full_command
}
"
.
red
)
end
end
end
end
output
case
output
when
:stdout
then
stdout
when
:stderr
then
stderr
else
stdout
+
stderr
end
end
end
# Returns the absolute path to the binary with the given name on the current
# Returns the absolute path to the binary with the given name on the current
...
...
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