提交 692fab26 编写于 作者: R Rafael França 提交者: GitHub

Merge pull request #30238 from bogdanvlviv/add-skip_yarn-for-plugin_generator

Add `--skip-yarn` option to the plugin generator
* Add `--skip-yarn` option to the plugin generator.
*bogdanvlviv*
* Optimize routes indentation.
*Yoshiyuki Hirano*
......
......@@ -27,7 +27,6 @@
<% unless options.skip_yarn? -%>
/node_modules
/yarn-error.log
<% end -%>
<% unless options.api? -%>
......
......@@ -89,7 +89,7 @@ def test
PASSTHROUGH_OPTIONS = [
:skip_active_record, :skip_action_mailer, :skip_javascript, :skip_action_cable, :skip_sprockets, :database,
:javascript, :api, :quiet, :pretend, :skip
:javascript, :skip_yarn, :api, :quiet, :pretend, :skip
]
def generate_test_dummy(force = false)
......
......@@ -5,5 +5,9 @@ pkg/
<%= dummy_path %>/db/*.sqlite3
<%= dummy_path %>/db/*.sqlite3-journal
<%= dummy_path %>/log/*.log
<% unless options[:skip_yarn] -%>
<%= dummy_path %>/node_modules/
<%= dummy_path %>/yarn-error.log
<% end -%>
<%= dummy_path %>/tmp/
<% end -%>
......@@ -584,32 +584,6 @@ def test_coffeescript_is_skipped_if_required
end
end
def test_generator_for_yarn
run_generator([destination_root])
assert_file "package.json", /dependencies/
assert_file "config/initializers/assets.rb", /node_modules/
assert_file ".gitignore" do |content|
assert_match(/node_modules/, content)
assert_match(/yarn-error\.log/, content)
end
end
def test_generator_for_yarn_skipped
run_generator([destination_root, "--skip-yarn"])
assert_no_file "package.json"
assert_no_file "bin/yarn"
assert_file "config/initializers/assets.rb" do |content|
assert_no_match(/node_modules/, content)
end
assert_file ".gitignore" do |content|
assert_no_match(/node_modules/, content)
assert_no_match(/yarn-error\.log/, content)
end
end
def test_inclusion_of_jbuilder
run_generator
assert_gem "jbuilder"
......
......@@ -26,6 +26,10 @@ class PluginGeneratorTest < Rails::Generators::TestCase
destination File.join(Rails.root, "tmp/bukkits")
arguments [destination_root]
def application_path
"#{destination_root}/test/dummy"
end
# brings setup, teardown, and some tests
include SharedGeneratorTests
......
......@@ -22,6 +22,10 @@ def teardown
Rails.application = TestApp::Application.instance
end
def application_path
destination_root
end
def test_skeleton_is_created
run_generator
......@@ -123,4 +127,30 @@ def test_skip_keeps
assert_no_file("app/models/concerns/.keep")
end
def test_generator_for_yarn
run_generator
assert_file "#{application_path}/package.json", /dependencies/
assert_file "#{application_path}/config/initializers/assets.rb", /node_modules/
assert_file ".gitignore" do |content|
assert_match(/node_modules/, content)
assert_match(/yarn-error\.log/, content)
end
end
def test_generator_for_yarn_skipped
run_generator([destination_root, "--skip-yarn"])
assert_no_file "#{application_path}/package.json"
assert_no_file "#{application_path}/bin/yarn"
assert_file "#{application_path}/config/initializers/assets.rb" do |content|
assert_no_match(/node_modules/, content)
end
assert_file ".gitignore" do |content|
assert_no_match(/node_modules/, content)
assert_no_match(/yarn-error\.log/, content)
end
end
end
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册