Permalink
Browse files

Wipe existing local template folder before writing

  • Loading branch information...
davidmerfield committed Jan 8, 2019
1 parent 685220a commit f3e1b70bf0d38c73c00a307392425b6f39285719
Showing with 17 additions and 8 deletions.
  1. +17 −8 app/modules/template/writeToFolder.js
@@ -28,20 +28,29 @@ function writeToFolder (blogID, templateID, callback) {

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);

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)
return next();
if (!view.name || !view.type || !view.content)
return next();

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

}, callback);
}, callback);
});
});
});
});

0 comments on commit f3e1b70

Please sign in to comment.