File tree Expand file tree Collapse file tree 4 files changed +22
-2
lines changed Expand file tree Collapse file tree 4 files changed +22
-2
lines changed Original file line number Diff line number Diff line change 11## Next Release
22
3+ * Add support for ` SPRING_QUIET ` environment variable.
4+
35## 4.0.0
46
57* Stop requiring ` set ` before bundler can select the proper version. This could result in
Original file line number Diff line number Diff line change @@ -389,6 +389,12 @@ a command runs:
389389Spring .quiet = true
390390```
391391
392+ You can also set the initial state of the ` quiet ` configuration option to true
393+ by setting the ` SPRING_QUIET ` environment variable before executing Spring.
394+ This is useful if you want to set quiet mode when invoking the Spring executable
395+ in a subprocess, and cannot or prefer not to set it programmatically
396+ via the ` Spring.quiet ` option in ` ~/.spring.rb ` or the app's ` config/spring.rb ` .
397+
392398### Environment variables
393399
394400The following environment variables are used by Spring:
@@ -413,6 +419,8 @@ The following environment variables are used by Spring:
413419 the long-running Spring server process. By default, this is related to
414420 the socket path; if the socket path is ` /foo/bar/spring.sock ` the
415421 pidfile will be ` /foo/bar/spring.pid ` .
422+ * ` SPRING_QUIET ` - If set, the initial state of the ` Spring.quiet `
423+ configuration option will default to ` true ` .
416424* ` SPRING_SERVER_COMMAND ` - The command to run to start up the Spring
417425 server when it is not already running. Defaults to `spring _ [ version] _
418426 server --background`.
Original file line number Diff line number Diff line change 22
33module Spring
44 class << self
5- attr_accessor :application_root , :quiet
5+ attr_accessor :application_root
6+ attr_writer :quiet
67
78 def gemfile
89 require "bundler"
@@ -52,6 +53,10 @@ def project_root_path
5253 @project_root_path ||= find_project_root ( Pathname . new ( File . expand_path ( Dir . pwd ) ) )
5354 end
5455
56+ def quiet
57+ @quiet ||= ENV . key? ( 'SPRING_QUIET' )
58+ end
59+
5560 private
5661
5762 def find_project_root ( current_dir )
Original file line number Diff line number Diff line change @@ -125,12 +125,17 @@ def without_gem(name)
125125 assert_success app . spring_test_command , stderr : "Running via Spring preloader in process"
126126 end
127127
128- test "does not tell the user that Spring is being used when used automatically via binstubs but quiet is enabled" do
128+ test "does not tell the user that Spring is being used when quiet is enabled via Spring.quiet " do
129129 File . write ( "#{ app . user_home } /.spring.rb" , "Spring.quiet = true" )
130130 assert_success "bin/rails runner ''"
131131 refute_output_includes "bin/rails runner ''" , stderr : 'Running via Spring preloader in process'
132132 end
133133
134+ test "does not tell the user that Spring is being used when quiet is enabled via SPRING_QUIET ENV var" do
135+ assert_success "SPRING_QUIET=true bin/rails runner ''"
136+ refute_output_includes "bin/rails runner ''" , stderr : 'Running via Spring preloader in process'
137+ end
138+
134139 test "raises if config.cache_classes is true" do
135140 config_path = app . path ( "config/environments/development.rb" )
136141 config = File . read ( config_path )
You can’t perform that action at this time.
0 commit comments