File tree Expand file tree Collapse file tree 2 files changed +23
-14
lines changed Expand file tree Collapse file tree 2 files changed +23
-14
lines changed Original file line number Diff line number Diff line change @@ -18,10 +18,15 @@ def run_task
18
18
success = true
19
19
20
20
FileUtils . chdir project . repo . path do
21
- out = capture_stdout do
21
+ out = capture ( :stderr ) do
22
22
success = Strano ::CLI . parse ( Strano ::Logger . new ( self ) , full_command . flatten ) . execute!
23
23
end
24
- puts "\n \e [1;32m> #{ out . string } \e " unless out . string . blank?
24
+
25
+ if out . is_a? ( String )
26
+ puts "\n \e [33m> #{ out } \e " unless out . blank?
27
+ elsif !out . string . blank?
28
+ puts "\n \e [1;32m> #{ out . string } \e "
29
+ end
25
30
end
26
31
27
32
!!success
@@ -49,13 +54,11 @@ def results
49
54
private
50
55
51
56
def full_command
52
- %W( -f #{ Rails . root . join ( 'Capfile.repos' ) } -f Capfile -Xx#{ verbosity } ) + mapped_variables + command . split ( ' ' )
57
+ %W( -f #{ Rails . root . join ( 'Capfile.repos' ) } -f Capfile -Xx#{ verbosity } ) + branch_setting + command . split ( ' ' )
53
58
end
54
59
55
- def mapped_variables
56
- variables . map do |k , v |
57
- %W( -s #{ k } =#{ v } ) unless v . blank?
58
- end
60
+ def branch_setting
61
+ %W( -s branch=#{ branch } ) unless branch . blank?
59
62
end
60
63
61
64
def execute_task
Original file line number Diff line number Diff line change 2
2
3
3
module Kernel
4
4
5
- def capture_stdout
6
- out = StringIO . new
7
- $stdout = out
8
- yield
9
- return out
10
- ensure
11
- $stdout = STDOUT
5
+ def capture ( stream )
6
+ return super if stream . is_a? ( String )
7
+
8
+ begin
9
+ stream = stream . to_s
10
+ eval "$#{ stream } = StringIO.new"
11
+ yield
12
+ result = eval ( "$#{ stream } " ) . string
13
+ ensure
14
+ eval ( "$#{ stream } = #{ stream . upcase } " )
15
+ end
16
+
17
+ result
12
18
end
13
19
14
20
end
You can’t perform that action at this time.
0 commit comments