mirror of
https://github.com/capistrano/capistrano
synced 2023-03-27 23:21:18 -04:00
feat: fallback ask to default when in non interactive run
This commit is contained in:
parent
92bfd11568
commit
3cff8cbdfa
3 changed files with 14 additions and 0 deletions
|
@ -19,6 +19,7 @@ gem "capistrano", github: "capistrano/capistrano", require: false
|
|||
[master]: https://github.com/capistrano/capistrano/compare/v3.10.2...HEAD
|
||||
|
||||
* Your contribution here!
|
||||
* [#1972](https://github.com/capistrano/capistrano/pull/1972): fallback ask to default when used in non interactive session
|
||||
|
||||
## [`3.10.2`] (2018-04-15)
|
||||
|
||||
|
|
|
@ -36,6 +36,8 @@ module Capistrano
|
|||
end
|
||||
|
||||
def gets
|
||||
return unless $stdin.tty?
|
||||
|
||||
if echo?
|
||||
$stdin.gets
|
||||
else
|
||||
|
|
|
@ -57,6 +57,17 @@ module Capistrano
|
|||
expect(question.call).to eq(branch)
|
||||
end
|
||||
end
|
||||
|
||||
context "tty unavailable" do
|
||||
before do
|
||||
$stdin.expects(:gets).never
|
||||
$stdin.expects(:tty?).returns(false)
|
||||
end
|
||||
|
||||
it "returns the default as the value" do
|
||||
expect(question.call).to eq(default)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue