Skip to content

Commit 5c6dcb5

Browse files
committed
fix: passthrough options correctly
1 parent 86c6bcc commit 5c6dcb5

File tree

4 files changed

+12
-5
lines changed

4 files changed

+12
-5
lines changed

Gemfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: .
33
specs:
4-
cr-exec (0.1.0)
4+
cr-exec (0.1.1)
55

66
GEM
77
remote: https://rubygems.org/

lib/cr/exec.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,12 @@ def output(*args, chomp: true)
3030
end
3131

3232
def each_line(*args, chomp: false, **options, &block)
33-
command = args.join(" ")
3433
if block
35-
IO.popen(command, options) do |pipe|
34+
IO.popen(*args, **options) do |pipe|
3635
pipe.each_line(chomp: chomp, &block)
3736
end
3837
else
39-
IO.popen(command, options).readlines(chomp: chomp)
38+
IO.popen(*args, **options).readlines(chomp: chomp)
4039
end
4140
end
4241

lib/cr/exec/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22

33
module Cr
44
module Exec
5-
VERSION = "0.1.0"
5+
VERSION = "0.1.1"
66
end
77
end

spec/cr/exec_spec.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,14 @@
4747
expect(Cr::Exec.each_line("ls spec", chomp: true)).to eq ["cr", "spec_helper.rb"]
4848
end
4949

50+
it "each_line with options" do
51+
expect(Cr::Exec.each_line("ls", chomp: true, chdir: "spec")).to eq ["cr", "spec_helper.rb"]
52+
end
53+
54+
it "each_line with ENV" do
55+
expect(Cr::Exec.each_line({ "FOO" => "bar" }, "echo $FOO", chomp: true)).to eq ["bar"]
56+
end
57+
5058
it "always return bool" do
5159
p system("unamea")
5260
expect(Cr::Exec.system?("unamea")).to eq false

0 commit comments

Comments
 (0)