Skip to content

Commit 09fbfd0

Browse files
Conditionally generate assets during setup
Clobber and precompile assets during setup if using [Sprockets][]. This is helpful in cases where one might switch branches frequently, which can result in broken assets. [Sprockets]: https://github.com/rails/sprockets
1 parent d283063 commit 09fbfd0

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

lib/generators/templates/setup/bin_setup.rb

+6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/usr/bin/env ruby
22
require "fileutils"
33
require "open3"
4+
require "rake"
45

56
# path to your application root.
67
APP_ROOT = File.expand_path("..", __dir__)
@@ -43,6 +44,11 @@ def using_node?
4344
puts "\n== Preparing database and adding development seed data =="
4445
system! "bin/rails dev:prime"
4546

47+
if Rake::Task.task_defined?("assets:clobber") && Rake::Task.task_defined("assets:precompile")
48+
puts "\n== Generating assets =="
49+
system! "bin/rails assets:clobber assets:precompile"
50+
end
51+
4652
# https://github.com/rails/rails/pull/47719/files
4753
puts "\n== Setup test environment =="
4854
system! "bin/rails test:prepare"

0 commit comments

Comments
 (0)