File tree Expand file tree Collapse file tree 3 files changed +29
-1
lines changed Expand file tree Collapse file tree 3 files changed +29
-1
lines changed Original file line number Diff line number Diff line change
1
+ ## Next release
2
+
3
+ * Preserve comments right after the shebang line which might include magic comments such as `frozen_string_literal: true'
4
+
1
5
## 2.0.2
2
6
3
7
* Fix reloading when a watched directory contains a dangling symlink (#522 )
Original file line number Diff line number Diff line change 3
3
module Spring
4
4
module Client
5
5
class Binstub < Command
6
- SHEBANG = /\# \! .*\n /
6
+ SHEBANG = /\# \! .*\n ( \# .* \n )* /
7
7
8
8
# If loading the bin/spring file works, it'll run spring which will
9
9
# eventually call Kernel.exit. This means that in the client process
Original file line number Diff line number Diff line change @@ -260,6 +260,30 @@ def exec_name
260
260
end
261
261
end
262
262
263
+ test "binstub preserve magic comments" do
264
+ File . write ( app . path ( "bin/rake" ) , <<-RUBY . strip_heredoc )
265
+ #!/usr/bin/env ruby
266
+ # frozen_string_literal: true
267
+ #
268
+ # more comments
269
+ require 'bundler/setup'
270
+ load Gem.bin_path('rake', 'rake')
271
+ RUBY
272
+
273
+ assert_success "bin/spring binstub rake"
274
+
275
+ expected = <<-RUBY . gsub ( /^ / , "" )
276
+ #!/usr/bin/env ruby
277
+ # frozen_string_literal: true
278
+ #
279
+ # more comments
280
+ #{ Spring ::Client ::Binstub ::LOADER . strip }
281
+ require 'bundler/setup'
282
+ load Gem.bin_path('rake', 'rake')
283
+ RUBY
284
+ assert_equal expected , app . path ( "bin/rake" ) . read
285
+ end
286
+
263
287
test "binstub upgrade with old binstub" do
264
288
File . write ( app . path ( "bin/rake" ) , <<-RUBY . strip_heredoc )
265
289
#!/usr/bin/env ruby
You can’t perform that action at this time.
0 commit comments