Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 7d0ac32

Browse files
author
Robert Mosolgo
authored
Merge pull request #703 from Najtmare/fix/webpacker_generator_not_camelizing_file_name
Camelize the file name when webpacker is defined
2 parents ac28d14 + abab872 commit 7d0ac32

File tree

4 files changed

+6
-4
lines changed

4 files changed

+6
-4
lines changed

‎lib/generators/react/component_generator.rb‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,17 +101,19 @@ def create_component_file
101101

102102
# Prefer webpacker to sprockets:
103103
if defined?(Webpacker)
104+
new_file_name = file_name.camelize
104105
extension = options[:coffee] ? "coffee" : "js"
105106
target_dir = Webpacker::Configuration.source_path
106107
.join("components")
107108
.relative_path_from(::Rails.root)
108109
.to_s
109110
else
111+
new_file_name = file_name
110112
extension = template_extension
111113
target_dir = 'app/assets/javascripts/components'
112114
end
113115

114-
file_path = File.join(target_dir, "#{file_name}.#{extension}")
116+
file_path = File.join(target_dir, "#{new_file_name}.#{extension}")
115117
template("component.#{template_extension}", file_path)
116118
end
117119

‎test/generators/coffee_component_generator_test.rb‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class CoffeeComponentGeneratorTest < Rails::Generators::TestCase
88

99
if WebpackerHelpers.available?
1010
def filename
11-
"app/javascript/components/generated_component.coffee"
11+
"app/javascript/components/GeneratedComponent.coffee"
1212
end
1313
else
1414
def filename

‎test/generators/component_generator_test.rb‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class ComponentGeneratorTest < Rails::Generators::TestCase
88

99
if WebpackerHelpers.available?
1010
def filename
11-
"app/javascript/components/generated_component.js"
11+
"app/javascript/components/GeneratedComponent.js"
1212
end
1313
else
1414
def filename

‎test/generators/es6_component_generator_test.rb‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class Es6ComponentGeneratorTest < Rails::Generators::TestCase
88

99
if WebpackerHelpers.available?
1010
def filename
11-
"app/javascript/components/generated_component.js"
11+
"app/javascript/components/GeneratedComponent.js"
1212
end
1313
else
1414
def filename

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /