Skip to content

Commit

Permalink
Guard against missing default entrypoint
Browse files Browse the repository at this point in the history
  • Loading branch information
dhh committed Sep 3, 2021
1 parent deec274 commit 5c5a85d
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/install/turbo_with_node.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
say "Import Turbo"
append_to_file "app/javascript/application.js", %(import "@hotwired/turbo-rails"\n)
if (js_entrypoint_path = Rails.root.join("app/javascript/application.js")).exist?
say "Import Turbo"
append_to_file "app/javascript/application.js", %(import "@hotwired/turbo-rails"\n)
else
say "You must import @hotwired/turbo-rails in your JavaScript entrypoint file", :red
end

say "Install Turbo"
run "npm i @hotwired/turbo-rails"

0 comments on commit 5c5a85d

Please sign in to comment.