Skip to content

Commit 8020d72

Browse files
committed
Improve output and logic in examples:bundle_install task
Refactored the :bundle_install task to enhance output clarity and correct the success/failure logic when running 'bundle install' in example folders. Now provides explicit success and failure messages for each folder and uses $CHILD_STATUS for process status.
1 parent 48f35de commit 8020d72

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

Rakefile

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -100,53 +100,53 @@ namespace :examples do
100100
desc 'Run bundle install on all example folders'
101101
task :bundle_install do
102102
examples_dir = File.join(Dir.pwd, 'examples')
103-
103+
104104
unless Dir.exist?(examples_dir)
105105
puts 'Examples directory not found'
106106
exit 1
107107
end
108-
108+
109109
example_folders = Dir.glob(File.join(examples_dir, '*')).select { |path| Dir.exist?(path) }
110-
110+
111111
if example_folders.empty?
112112
puts 'No example folders found'
113113
return
114114
end
115-
115+
116116
puts "Found #{example_folders.length} example folders:"
117117
example_folders.each { |folder| puts " - #{File.basename(folder)}" }
118118
puts
119-
119+
120120
failed_folders = []
121-
121+
122122
example_folders.each do |folder|
123123
gemfile_path = File.join(folder, 'Gemfile')
124-
124+
125125
unless File.exist?(gemfile_path)
126126
puts "Skipping #{File.basename(folder)} - no Gemfile found"
127127
next
128128
end
129-
129+
130130
puts "Running bundle install in #{File.basename(folder)}..."
131-
131+
132132
Dir.chdir(folder) do
133133
system('bundle install')
134-
135-
unless $?.success?
134+
135+
if $CHILD_STATUS.success?
136+
puts " ✓ Successfully installed gems in #{File.basename(folder)}"
137+
else
136138
failed_folders << File.basename(folder)
137139
puts " ✗ Failed to bundle install in #{File.basename(folder)}"
138-
else
139-
puts " ✓ Successfully installed gems in #{File.basename(folder)}"
140140
end
141141
end
142-
142+
143143
puts
144144
end
145-
145+
146146
if failed_folders.empty?
147147
puts 'All example folders processed successfully!'
148148
else
149-
puts "Failed to process #{failed_folders.length} folders: #{failed_folders.join(', ')}"
149+
puts "Failed to process #{failed_folders.length} folders: #{failed_folders.join(", ")}"
150150
exit 1
151151
end
152152
end

0 commit comments

Comments
 (0)