Skip to content

Commit 3bac270

Browse files
committed
Merge pull request #429 from BanzaiMan/no_sed
Eschew use of `sed`
2 parents 71a0058 + 24391e6 commit 3bac270

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

tasks/rspec.rake

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,26 @@ file 'spec/configuration.yml' => 'spec/configuration.yml.example' do |task|
3636
CLEAN.exclude task.name
3737
src_path = File.expand_path("../../#{task.prerequisites.first}", __FILE__)
3838
dst_path = File.expand_path("../../#{task.name}", __FILE__)
39-
cp src_path, dst_path
40-
sh "sed -i 's/LOCALUSERNAME/#{ENV['USER']}/' #{dst_path}"
39+
40+
dst_file = File.open(dst_path, 'w')
41+
File.open(src_path) do |f|
42+
f.each_line do |line|
43+
dst_file.write line.gsub(/LOCALUSERNAME/, ENV['USER'])
44+
end
45+
end
4146
end
4247

4348
file 'spec/my.cnf' => 'spec/my.cnf.example' do |task|
4449
CLEAN.exclude task.name
4550
src_path = File.expand_path("../../#{task.prerequisites.first}", __FILE__)
4651
dst_path = File.expand_path("../../#{task.name}", __FILE__)
47-
cp src_path, dst_path
48-
sh "sed -i 's/LOCALUSERNAME/#{ENV['USER']}/' #{dst_path}"
52+
53+
dst_file = File.open(dst_path, 'w')
54+
File.open(src_path) do |f|
55+
f.each_line do |line|
56+
dst_file.write line.gsub(/LOCALUSERNAME/, ENV['USER'])
57+
end
58+
end
4959
end
5060

5161
Rake::Task[:spec].prerequisites << :'spec/configuration.yml'

0 commit comments

Comments
 (0)