Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: fallback ask to default when used in non interactive session #1972

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -19,6 +19,7 @@ gem "capistrano", github: "capistrano/capistrano", require: false
[master]: https://github.com/capistrano/capistrano/compare/v3.10.1...HEAD

* Your contribution here!
* [#1972](https://github.com/capistrano/capistrano/pull/1972): fallback ask to default when used in non interactive session

## [`3.10.1`] (2017-12-08)

Expand Down
2 changes: 2 additions & 0 deletions lib/capistrano/configuration/question.rb
Expand Up @@ -36,6 +36,8 @@ def response
end

def gets
return unless $stdin.tty?

if echo?
$stdin.gets
else
Expand Down
11 changes: 11 additions & 0 deletions spec/lib/capistrano/configuration/question_spec.rb
Expand Up @@ -57,6 +57,17 @@ class Configuration
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
Expand Down