Skip to content

Set quiet mode from environment #577

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

Closed
wants to merge 1 commit into from
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* Preserve comments right after the shebang line which might include magic comments such as `frozen_string_literal: true'
* Fix binstub failures when Bundler's `BUNDLE_APP_CONFIG` environment variable is present (#545)
* Properly suspend and resume on ctrl-z TSTP and CONT (#361)
* Allow quiet mode to be set by environment variable `SPRING_QUIET`

## 2.0.2

Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,8 @@ The following environment variables are used by Spring:
* `SPRING_SERVER_COMMAND` - The command to run to start up the Spring
server when it is not already running. Defaults to `spring _[version]_
server --background`.

* `SPRING_QUIET` - If set, the "Running via Spring preloader" message will not
be shown each time a command runs (takes precedence over `Spring.quiet`).
## Troubleshooting

If you want to get more information about what Spring is doing, you can
Expand Down
7 changes: 6 additions & 1 deletion lib/spring/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

module Spring
class << self
attr_accessor :application_root, :quiet
attr_accessor :application_root
attr_writer :quiet

def gemfile
ENV['BUNDLE_GEMFILE'] || "Gemfile"
Expand All @@ -16,6 +17,10 @@ def after_fork(&block)
after_fork_callbacks << block
end

def quiet
@quiet || ENV.key?('SPRING_QUIET')
end

def verify_environment
application_root_path
end
Expand Down
6 changes: 6 additions & 0 deletions lib/spring/test/acceptance_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,12 @@ def without_gem(name)
refute_output_includes "bin/rails runner ''", stderr: 'Running via Spring preloader in process'
end

test "configures quiet mode from environment" do
app.env['SPRING_QUIET'] = '1'
assert_success "bin/rails runner ''"
refute_output_includes "bin/rails runner ''", stderr: 'Running via Spring preloader in process'
end

test "test changes are picked up" do
assert_speedup do
assert_success app.spring_test_command, stdout: "0 failures"
Expand Down