mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Overwrite bin/yarn when running app:binstub:yarn
This ensures that commands which delegate to `app:binstub:yarn`, such as `action_text:install`, will update `bin/yarn`.
This commit is contained in:
parent
a27567596b
commit
6e78549d2c
2 changed files with 17 additions and 3 deletions
|
@ -107,9 +107,7 @@ module Rails
|
|||
end
|
||||
|
||||
def yarn_when_updating
|
||||
return if File.exist?("bin/yarn")
|
||||
|
||||
template "bin/yarn" do |content|
|
||||
template "bin/yarn", force: true do |content|
|
||||
"#{shebang}\n" + content
|
||||
end
|
||||
|
||||
|
|
|
@ -301,6 +301,22 @@ module ApplicationTests
|
|||
end
|
||||
end
|
||||
|
||||
test "app:binstub:yarn generates bin/yarn" do
|
||||
yarn_binstub = File.join(app_path, "bin/yarn")
|
||||
rails "app:binstub:yarn"
|
||||
|
||||
assert_path_exists yarn_binstub
|
||||
assert_match %r/\A#!/, File.read(yarn_binstub)
|
||||
end
|
||||
|
||||
test "app:binstub:yarn overwrites existing bin/yarn" do
|
||||
yarn_binstub = File.join(app_path, "bin/yarn")
|
||||
File.write(yarn_binstub, "existing")
|
||||
rails "app:binstub:yarn"
|
||||
|
||||
assert_match %r/\A#!/, File.read(yarn_binstub)
|
||||
end
|
||||
|
||||
def test_template_load_initializers
|
||||
app_file "config/initializers/dummy.rb", "puts 'Hello, World!'"
|
||||
app_file "template.rb", ""
|
||||
|
|
Loading…
Reference in a new issue