Skip to content

Commit 51dec1a

Browse files
committed
Fix binstubs not being replaced when their quoting style was changed
1 parent fd5cb71 commit 51dec1a

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
## Next release
22

3+
* Fix binstubs not being replaced when their quoting style was changed (#534)
34
* Preserve comments right after the shebang line which might include magic comments such as `frozen_string_literal: true'
45

56
## 2.0.2

lib/spring/client/binstub.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,10 @@ class Binstub < Command
4646
OLD_BINSTUB = %{if !Process.respond_to?(:fork) || Gem::Specification.find_all_by_name("spring").empty?}
4747

4848
BINSTUB_VARIATIONS = Regexp.union [
49-
%{begin\n load File.expand_path("../spring", __FILE__)\nrescue LoadError\nend\n},
5049
%{begin\n load File.expand_path('../spring', __FILE__)\nrescue LoadError\nend\n},
5150
%{begin\n spring_bin_path = File.expand_path('../spring', __FILE__)\n load spring_bin_path\nrescue LoadError => e\n raise unless e.message.end_with? spring_bin_path, 'spring/binstub'\nend\n},
5251
LOADER
53-
]
52+
].map { |binstub| /#{Regexp.escape(binstub).gsub("'", "['\"]")}/ }
5453

5554
class Item
5655
attr_reader :command, :existing

lib/spring/test/acceptance_test.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,9 @@ def exec_name
237237
assert_success "#{app.spring} binstub --remove rake", stdout: "bin/rake: spring removed"
238238
assert !app.path("bin/rake").read.include?(Spring::Client::Binstub::LOADER)
239239
assert_success "bin/rake -T", stdout: "rake db:migrate"
240+
241+
assert_success "#{app.spring} binstub rake", stdout: "bin/rake: spring inserted"
242+
assert app.path("bin/rake").read.include?(Spring::Client::Binstub::LOADER)
240243
end
241244

242245
test "binstub remove all" do

0 commit comments

Comments
 (0)