mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Removal of javascript related gems when creating an app
Commit 0417bc8
add the coffee-rails and javascript runtime gems even
when passing the --skip-javascript option but this is not the desired
behavior.
Also remove all javascript related stuff in the generated application
such as the vendor/assets/javascripts folder.
This commit is contained in:
parent
f230dbf699
commit
84e261b930
5 changed files with 21 additions and 14 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
* Removal of all javascript stuff (gems and files) when generating a new
|
||||||
|
application using the `--skip-javascript` option.
|
||||||
|
|
||||||
|
*Robin Dupret*
|
||||||
|
|
||||||
* Make the application name snake cased when it contains spaces
|
* Make the application name snake cased when it contains spaces
|
||||||
|
|
||||||
The application name is used to fill the `database.yml` and
|
The application name is used to fill the `database.yml` and
|
||||||
|
|
|
@ -207,13 +207,6 @@ module Rails
|
||||||
gem 'uglifier', '>= 1.3.0'
|
gem 'uglifier', '>= 1.3.0'
|
||||||
GEMFILE
|
GEMFILE
|
||||||
|
|
||||||
if options[:skip_javascript]
|
|
||||||
gemfile += <<-GEMFILE
|
|
||||||
#{coffee_gemfile_entry}
|
|
||||||
#{javascript_runtime_gemfile_entry}
|
|
||||||
GEMFILE
|
|
||||||
end
|
|
||||||
|
|
||||||
gemfile.gsub(/^[ \t]+/, '')
|
gemfile.gsub(/^[ \t]+/, '')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -129,7 +129,9 @@ module Rails
|
||||||
end
|
end
|
||||||
|
|
||||||
def vendor_javascripts
|
def vendor_javascripts
|
||||||
empty_directory_with_keep_file 'vendor/assets/javascripts'
|
unless options[:skip_javascript]
|
||||||
|
empty_directory_with_keep_file 'vendor/assets/javascripts'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def vendor_stylesheets
|
def vendor_stylesheets
|
||||||
|
@ -225,6 +227,12 @@ module Rails
|
||||||
build(:leftovers)
|
build(:leftovers)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def delete_js_folder_skipping_javascript
|
||||||
|
if options[:skip_javascript]
|
||||||
|
remove_dir 'app/assets/javascripts'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
public_task :apply_rails_template, :run_bundle
|
public_task :apply_rails_template, :run_bundle
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
<title><%= camelized %></title>
|
<title><%= camelized %></title>
|
||||||
<%- if options[:skip_javascript] -%>
|
<%- if options[:skip_javascript] -%>
|
||||||
<%%= stylesheet_link_tag "application", media: "all" %>
|
<%%= stylesheet_link_tag "application", media: "all" %>
|
||||||
<%%= javascript_include_tag "application" %>
|
|
||||||
<%- else -%>
|
<%- else -%>
|
||||||
<%%= stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => true %>
|
<%%= stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => true %>
|
||||||
<%%= javascript_include_tag "application", "data-turbolinks-track" => true %>
|
<%%= javascript_include_tag "application", "data-turbolinks-track" => true %>
|
||||||
|
|
|
@ -298,15 +298,17 @@ class AppGeneratorTest < Rails::Generators::TestCase
|
||||||
|
|
||||||
def test_javascript_is_skipped_if_required
|
def test_javascript_is_skipped_if_required
|
||||||
run_generator [destination_root, "--skip-javascript"]
|
run_generator [destination_root, "--skip-javascript"]
|
||||||
assert_file "app/assets/javascripts/application.js" do |contents|
|
|
||||||
assert_no_match %r{^//=\s+require\s}, contents
|
assert_no_file "app/assets/javascripts"
|
||||||
end
|
assert_no_file "vendor/assets/javascripts"
|
||||||
|
|
||||||
assert_file "app/views/layouts/application.html.erb" do |contents|
|
assert_file "app/views/layouts/application.html.erb" do |contents|
|
||||||
assert_match(/stylesheet_link_tag\s+"application", media: "all" %>/, contents)
|
assert_match(/stylesheet_link_tag\s+"application", media: "all" %>/, contents)
|
||||||
assert_match(/javascript_include_tag\s+"application" \%>/, contents)
|
assert_no_match(/javascript_include_tag\s+"application" \%>/, contents)
|
||||||
end
|
end
|
||||||
|
|
||||||
assert_file "Gemfile" do |content|
|
assert_file "Gemfile" do |content|
|
||||||
assert_match(/coffee-rails/, content)
|
assert_no_match(/coffee-rails/, content)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue