'use strict';

var _ = require('lodash'),
    async = require('async'),
    copyr = require('cp-r'),
    rmdir = require('rmdir'),
    Source = require('./render/source'),
    Meta = require('./render/meta'),
    Page = require('./render/page');

function renderAll(data, done) {
    var tasks = [].concat(data.home, data.posts, data.pages, _.values(data.categories));

    async.each(tasks, function(post, next) {
        Page.render(post, data, next);
    }, done);
}

function run(options, done) {

    rmdir(options.target, function() {
        async.waterfall([
            _.partial(Source.import, options),
            _.partial(Meta.import, options),
            renderAll,
            function(next) {
                copyr(options.assets, options.target).read(function() {
                    next();
                });
            }
        ], done);
    });
}

module.exports = run;

@@ -255,19 +255,16 @@
 n render
-All
 (data, d
@@ -671,11 +671,8 @@
 nder
-All
 ,%0A  

rename fn