lib/middleman-slim/template.rb in middleman-slim-0.1.1 vs lib/middleman-slim/template.rb in middleman-slim-0.1.2

- old
+ new

@@ -37,17 +37,21 @@ copy_file 'source/images/middleman.png', File.join(location, 'source', options[:images_dir], 'middleman.png') end private def replace_images_dir - f = File.open(File.join(location, 'source', options[:css_dir], 'all.css'), 'r') - buf = f.read - buf.gsub!(/IMG_DIR/, options[:images_dir]) - f.close + if options[:images_dir] == 'images' + return + end - f = File.open(File.join(location, 'source', options[:css_dir], 'all.css'), 'w') - f.write(buf) - f.close + open(File.join(location, 'source', options[:css_dir], 'all.css'), 'r+') {|f| + f.flock(File::LOCK_EX) + body = f.read + body = body.gsub(/images/, options[:images_dir]) + f.rewind + f.puts body + f.truncate(f.tell) + } end end end end