Skip to content

Commit

Permalink
Create directories if they don't exist
Browse files Browse the repository at this point in the history
  • Loading branch information
Mat Brown committed Aug 17, 2009
1 parent 95f7200 commit 6f9c40a
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/config_puller.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
require 'fileutils'

class ConfigPuller
ConfigRequestError = Class.new(StandardError)

Expand All @@ -13,7 +15,9 @@ def pull(files, branch)
puts request_path
response = http.get(request_path)
if response.code == '200'
File.open("caproot/#{path}", 'w') { |f| f << response.body }
file_path = "caproot/#{path}"
FileUtils.mkdir_p(File.dirname(file_path))
File.open(file_path, 'w') { |f| f << response.body }
else
raise ConfigRequestError, "Got response code #{response.code} when requesting #{request_path}"
end
Expand Down

0 comments on commit 6f9c40a

Please sign in to comment.