Skip to content

Commit

Permalink
Simplify generators main running loop
Browse files Browse the repository at this point in the history
  • Loading branch information
AliOsm committed Sep 1, 2024
1 parent 2e67241 commit af7883b
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 36 deletions.
10 changes: 1 addition & 9 deletions generators/bootstrap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,7 @@ def view_template
}.freeze

def main
clone_repo(REPO_URL, REPO_NAME)
prepare_phlex_icons_pack_directory(ICONS_PACK_PATH)

print '⌛ Creating icon components...'
icon_file_paths.tqdm.each { create_icon_component(_1) }
puts "\r🎉 Icon components created successfully!"

run_rubocop(ICONS_PACK_PATH)
delete_repo(REPO_NAME)
run_generator { icon_file_paths.tqdm.each { create_icon_component(_1) } }
end

def icon_file_paths
Expand Down
10 changes: 1 addition & 9 deletions generators/flag.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,7 @@ def rectangle
TEMPLATE

def main
clone_repo(REPO_URL, REPO_NAME)
prepare_phlex_icons_pack_directory(ICONS_PACK_PATH)

print '⌛ Creating icon components...'
icon_file_names.tqdm.each { create_icon_component(_1) }
puts "\r🎉 Icon components created successfully!"

run_rubocop(ICONS_PACK_PATH)
delete_repo(REPO_NAME)
run_generator { icon_file_names.tqdm.each { create_icon_component(_1) } }
end

def icon_file_names
Expand Down
12 changes: 12 additions & 0 deletions generators/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,18 @@
Metrics/MethodLength
].join(',')

def run_generator(&block)
clone_repo(REPO_URL, REPO_NAME)
prepare_phlex_icons_pack_directory(ICONS_PACK_PATH)

print '⌛ Creating icon components...'
yield block
puts "\r🎉 Icon components created successfully!"

run_rubocop(ICONS_PACK_PATH)
delete_repo(REPO_NAME)
end

def clone_repo(repo_url, repo_name)
print "⌛ Cloning '#{repo_name}' repo..."

Expand Down
10 changes: 1 addition & 9 deletions generators/hero.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,7 @@ def outline
TEMPLATE

def main
clone_repo(REPO_URL, REPO_NAME)
prepare_phlex_icons_pack_directory(ICONS_PACK_PATH)

print '⌛ Creating icon components...'
icon_file_names.tqdm.each { create_icon_component(_1) }
puts "\r🎉 Icon components created successfully!"

run_rubocop(ICONS_PACK_PATH)
delete_repo(REPO_NAME)
run_generator { icon_file_names.tqdm.each { create_icon_component(_1) } }
end

def icon_file_names
Expand Down
10 changes: 1 addition & 9 deletions generators/lucide.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,7 @@ def view_template
TEMPLATE

def main
clone_repo(REPO_URL, REPO_NAME)
prepare_phlex_icons_pack_directory(ICONS_PACK_PATH)

print '⌛ Creating icon components...'
icon_file_paths.tqdm.each { create_icon_component(_1) }
puts "\r🎉 Icon components created successfully!"

run_rubocop(ICONS_PACK_PATH)
delete_repo(REPO_NAME)
run_generator { icon_file_paths.tqdm.each { create_icon_component(_1) } }
end

def icon_file_paths
Expand Down

0 comments on commit af7883b

Please sign in to comment.