Skip to content

Commit e0be4f7

Browse files
committed
Make sure generated files are closed before we try to use them
1 parent 84d78eb commit e0be4f7

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

tasks/rspec.rake

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,8 @@ file 'spec/configuration.yml' => 'spec/configuration.yml.example' do |task|
3737
src_path = File.expand_path("../../#{task.prerequisites.first}", __FILE__)
3838
dst_path = File.expand_path("../../#{task.name}", __FILE__)
3939

40-
dst_file = File.open(dst_path, 'w')
41-
File.open(src_path) do |f|
42-
f.each_line do |line|
40+
File.open(dst_path, 'w') do |dst_file|
41+
File.open(src_path).each_line do |line|
4342
dst_file.write line.gsub(/LOCALUSERNAME/, ENV['USER'])
4443
end
4544
end
@@ -50,9 +49,8 @@ file 'spec/my.cnf' => 'spec/my.cnf.example' do |task|
5049
src_path = File.expand_path("../../#{task.prerequisites.first}", __FILE__)
5150
dst_path = File.expand_path("../../#{task.name}", __FILE__)
5251

53-
dst_file = File.open(dst_path, 'w')
54-
File.open(src_path) do |f|
55-
f.each_line do |line|
52+
File.open(dst_path, 'w') do |dst_file|
53+
File.open(src_path).each_line do |line|
5654
dst_file.write line.gsub(/LOCALUSERNAME/, ENV['USER'])
5755
end
5856
end

0 commit comments

Comments
 (0)