Skip to content

Commit

Permalink
Wipe existing local template folder before writing
Browse files Browse the repository at this point in the history
  • Loading branch information
davidmerfield committed Jan 8, 2019
1 parent 685220a commit f3e1b70
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions app/modules/template/writeToFolder.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -28,20 +28,29 @@ function writeToFolder (blogID, templateID, callback) {


makeClient(blogID, function(err, client){ makeClient(blogID, function(err, client){


if (err) console.log(err); if (err) {

return callback(err);
if (err) return callback(err); }


var dir = joinpath('Templates', metadata.slug); var dir = joinpath('Templates', metadata.slug);


async.eachOfSeries(views, function(view, name, next){ // Reset the folder before writing. This fixes a bug in which
// there were two views with the same name, but different extension.
client.remove(blogID, dir, function(err){

if (err) {
return callback(err);
}

async.eachOfSeries(views, function(view, name, next){


if (!view.name || !view.type || !view.content) if (!view.name || !view.type || !view.content)
return next(); return next();


write(blogID, client, dir, view, next); write(blogID, client, dir, view, next);


}, callback); }, callback);
});
}); });
}); });
}); });
Expand Down

0 comments on commit f3e1b70

Please sign in to comment.