lucie-cmd 0.0.16 → 0.0.17
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/lucie-cmd/commands.rb +12 -2
- data/test/functional/cd_test.rb +8 -0
- data/test/functional/sh_test.rb +8 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5537cb96d16031222139051be054987547495fa2
|
4
|
+
data.tar.gz: 45d42fac474693b0dcdcd33c9f9ef2f110a22c86
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ea3d0d167e371a8240bad8a5317815e2c853d420782dde1f5496fe4f803b0b622ebf106d58413cbbc038a04f65de458ccfff310c5ef2ba623d8c83bf5371a7fe
|
7
|
+
data.tar.gz: 991256bafd7ec65ab0311f3c7b228d45b18dadb6a0d0b189141f22fc61ee4c91e112d5e6d9c5d3208515e6c4e328401b0c8b623f74de2fb06e623d75c8ebc045
|
data/lib/lucie-cmd/commands.rb
CHANGED
@@ -81,15 +81,22 @@ module Lucie
|
|
81
81
|
end
|
82
82
|
|
83
83
|
@status = Open4::popen4("cd \"#{pwd}\" && #{command}") do |pid, stdin, stdout, stderr|
|
84
|
-
@
|
84
|
+
@pid = pid
|
85
85
|
@output = ""
|
86
|
-
if !stdout.eof
|
86
|
+
if !stdout.eof
|
87
87
|
new_content = stdout.read
|
88
88
|
if @opts.include? :live_output
|
89
89
|
print new_content
|
90
90
|
end
|
91
91
|
@output << new_content
|
92
92
|
end
|
93
|
+
if !stderr.eof
|
94
|
+
new_content = stderr.read
|
95
|
+
if @opts.include? :live_output
|
96
|
+
@stderr.print new_content
|
97
|
+
end
|
98
|
+
@output << new_content
|
99
|
+
end
|
93
100
|
end
|
94
101
|
end
|
95
102
|
|
@@ -103,6 +110,9 @@ module Lucie
|
|
103
110
|
|
104
111
|
def pwd=(val)
|
105
112
|
@pwd = File.expand_path(val, @pwd)
|
113
|
+
if @opts.include? :live_output
|
114
|
+
puts "$ cd '#{@pwd}'"
|
115
|
+
end
|
106
116
|
end
|
107
117
|
|
108
118
|
def set(opts = [])
|
data/test/functional/cd_test.rb
CHANGED
@@ -23,4 +23,12 @@ class CdTest < MiniTest::Spec
|
|
23
23
|
sh "pwd"
|
24
24
|
assert_equal "/sbin\n", output
|
25
25
|
end
|
26
|
+
|
27
|
+
it "should log the cd path on console when live_output is on" do
|
28
|
+
out, err = capture_io do
|
29
|
+
set :live_output
|
30
|
+
cd "/tmp"
|
31
|
+
end
|
32
|
+
assert_equal "$ cd '/tmp'\n", out
|
33
|
+
end
|
26
34
|
end
|
data/test/functional/sh_test.rb
CHANGED
@@ -79,6 +79,14 @@ class ShTest < MiniTest::Spec
|
|
79
79
|
assert_equal "", out
|
80
80
|
end
|
81
81
|
|
82
|
+
it "should log stderr when live_output is on" do
|
83
|
+
_, err = capture_io do
|
84
|
+
set :live_output
|
85
|
+
sh "echo test 1>&2"
|
86
|
+
end
|
87
|
+
assert_equal "test\n", err
|
88
|
+
end
|
89
|
+
|
82
90
|
it "should be able to use green color for output" do
|
83
91
|
out, err = capture_io do
|
84
92
|
green "Hello world"
|