Merge pull request #41399 from jonathanhefner/always-overwrite-bin-yarn

Overwrite bin/yarn when running app:binstub:yarn
This commit is contained in:
Rafael França 2021-02-10 19:08:29 -05:00 committed by GitHub
commit 3b9a877c69
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 3 deletions

View File

@ -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

View File

@ -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", ""