Skip to content

Commit 7638f92

Browse files
Use Thor's apply instead of a prerequisite task (#150)
The `css:install:shared` task serves only as a prerequisite for the other installer tasks; it should not be run on its own (nor listed with `rake --tasks`). By replacing this task with corresponding calls to Thor's `apply` method, we avoid the overhead of running `bin/rails app:template` (and `bundle install`) multiple times.
1 parent 02caad4 commit 7638f92

File tree

6 files changed

+15
-10
lines changed

6 files changed

+15
-10
lines changed

lib/install/bootstrap/install.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
require_relative "../helpers"
22
self.extend Helpers
33

4+
apply "#{__dir__}/../install.rb"
5+
46
say "Install Bootstrap with Bootstrap Icons, Popperjs/core and Autoprefixer"
57
copy_file "#{__dir__}/application.bootstrap.scss",
68
"app/assets/stylesheets/application.bootstrap.scss"

lib/install/bulma/install.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
require_relative "../helpers"
22
self.extend Helpers
33

4+
apply "#{__dir__}/../install.rb"
5+
46
say "Install Bulma"
57
copy_file "#{__dir__}/application.bulma.scss",
68
"app/assets/stylesheets/application.bulma.scss"

lib/install/postcss/install.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
require_relative "../helpers"
22
self.extend Helpers
33

4+
apply "#{__dir__}/../install.rb"
5+
46
say "Install PostCSS w/ nesting and autoprefixer"
57
copy_file "#{__dir__}/postcss.config.js", "postcss.config.js"
68
copy_file "#{__dir__}/application.postcss.css", "app/assets/stylesheets/application.postcss.css"

lib/install/sass/install.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
require_relative "../helpers"
22
self.extend Helpers
33

4+
apply "#{__dir__}/../install.rb"
5+
46
say "Install Sass"
57
copy_file "#{__dir__}/application.sass.scss", "app/assets/stylesheets/application.sass.scss"
68
run "#{bundler_cmd} add sass"

lib/install/tailwind/install.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
require_relative "../helpers"
22
self.extend Helpers
33

4+
apply "#{__dir__}/../install.rb"
5+
46
say "Install Tailwind (+PostCSS w/ autoprefixer)"
57
copy_file "#{__dir__}/tailwind.config.js", "tailwind.config.js"
68
copy_file "#{__dir__}/application.tailwind.css", "app/assets/stylesheets/application.tailwind.css"

lib/tasks/cssbundling/install.rake

+5-10
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,27 @@
11
namespace :css do
22
namespace :install do
3-
desc "Install shared elements for all bundlers"
4-
task :shared do
5-
system "#{RbConfig.ruby} ./bin/rails app:template LOCATION=#{File.expand_path("../../install/install.rb", __dir__)}"
6-
end
7-
83
desc "Install Tailwind"
9-
task tailwind: "css:install:shared" do
4+
task :tailwind do
105
system "#{RbConfig.ruby} ./bin/rails app:template LOCATION=#{File.expand_path("../../install/tailwind/install.rb", __dir__)}"
116
end
127

138
desc "Install PostCSS"
14-
task postcss: "css:install:shared" do
9+
task :postcss do
1510
system "#{RbConfig.ruby} ./bin/rails app:template LOCATION=#{File.expand_path("../../install/postcss/install.rb", __dir__)}"
1611
end
1712

1813
desc "Install Sass"
19-
task sass: "css:install:shared" do
14+
task :sass do
2015
system "#{RbConfig.ruby} ./bin/rails app:template LOCATION=#{File.expand_path("../../install/sass/install.rb", __dir__)}"
2116
end
2217

2318
desc "Install Bootstrap"
24-
task bootstrap: "css:install:shared" do
19+
task :bootstrap do
2520
system "#{RbConfig.ruby} ./bin/rails app:template LOCATION=#{File.expand_path("../../install/bootstrap/install.rb", __dir__)}"
2621
end
2722

2823
desc "Install Bulma"
29-
task bulma: "css:install:shared" do
24+
task :bulma do
3025
system "#{RbConfig.ruby} ./bin/rails app:template LOCATION=#{File.expand_path("../../install/bulma/install.rb", __dir__)}"
3126
end
3227
end

0 commit comments

Comments
 (0)