Skip to content

Commit

Permalink
Remove files before import new and namespace folders
Browse files Browse the repository at this point in the history
  • Loading branch information
Brice Sanchez committed Nov 7, 2016
1 parent 851968a commit a444df4
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions lib/middleman-refinery/commands/refinery.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
require 'json'
require 'date'
require 'fileutils'
require 'pry'

module Middleman
module Cli
Expand Down Expand Up @@ -32,10 +33,6 @@ def self.exit_on_failure?
def refinery
::Middleman::Application.new

Dir.mkdir('data') unless File.exists?('data')

FileUtils.rm_rf(Dir.glob('data/refinery_*'))

::Refinery::API.configure do |conf|
conf.api_token = configs.api_token
conf.api_url = configs.api_url
Expand All @@ -46,15 +43,15 @@ def refinery
content = eval("::Refinery::API::#{ct[:content_type]}.new")
content_index_body = JSON.parse(content.index.body)
content_type_param = ct[:content_type].parameterize
destination = "#{ct[:destination] || 'data'}/#{content_type_param}"
destination = "#{ct[:destination] || 'data'}/refinery/#{content_type_param}"
format = ct[:format] || '.yml'
node = ct[:node]

if content_index_body.has_key?("error")
say_status "Skip: `#{content_index_body}`"
else

FileUtils.mkdir_p destination
FileUtils.mkdir_p destination unless File.exists?(destination)
FileUtils.rm_rf(Dir.glob("#{destination}/*"))

content_index_body[node].each do |content|
if node == 'posts'
Expand Down

0 comments on commit a444df4

Please sign in to comment.