Skip to content

Commit 88a90af

Browse files
committed
fix generated components dir
1 parent ffe0347 commit 88a90af

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

lib/generators/react/install_generator.rb

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,14 @@ class InstallGenerator < ::Rails::Generators::Base
1818

1919
# Make an empty `components/` directory in the right place:
2020
def create_directory
21-
empty_directory File.join(javascript_dir, 'components')
21+
components_dir = if webpacker?
22+
Pathname.new(javascript_dir).parent.to_s
23+
else
24+
javascript_dir
25+
end
26+
empty_directory File.join(components_dir, 'components')
2227
if !options[:skip_git]
23-
create_file File.join(javascript_dir, 'components/.gitkeep')
28+
create_file File.join(components_dir, 'components/.gitkeep')
2429
end
2530
end
2631

test/generators/install_generator_webpacker_test.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ def copy_directory(dir)
2626
test "adds requires to `application.js`" do
2727
run_generator
2828
assert_file "app/javascript/packs/application.js", EXPECTED_SETUP
29+
assert_file "app/javascript/components"
2930
end
3031

3132
test "creates server_rendering.js with default requires" do

0 commit comments

Comments
 (0)