Skip to content

Commit

Permalink
Tweaked local client setup
Browse files Browse the repository at this point in the history
  • Loading branch information
davidmerfield committed Feb 11, 2019
1 parent f7e191e commit 90bcd5f
Showing 1 changed file with 23 additions and 13 deletions.
36 changes: 23 additions & 13 deletions app/clients/local/controllers/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,28 @@ var Folder = require("../models/folder");
var async = require("async");
var debug = require("debug")("blot:clients:local:setup");
var watch = require("./watch");
var walk = require('./util/walk');
var hash = require('./util/hash');
var walk = require("./util/walk");
var hash = require("./util/hash");
var config = require("config");

// Start listening for all blogs with this client
Folder.list(function(err, blogIDs) {
if (err) throw err;
blogIDs.forEach(function(blogID) {
Folder.get(blogID, function(err, folder) {
if (err) throw err;
if (!folder) return;
setup(blogID, folder, function(err) {
if (err) throw err;
if (config.environment === "development") {
Folder.list(function(err, blogIDs) {
if (err) console.error(err);
blogIDs.forEach(function(blogID) {
Folder.get(blogID, function(err, folder) {
if (err) console.error(err);
if (!folder) return;

watch(blogID, folder);

synchronize(blogID, folder, function(err) {
if (err) console.error(err);
});
});
});
});
});
}

function setup(blogID, folder, callback) {
debug("Setting up local client in", folder);
Expand All @@ -31,8 +37,12 @@ function setup(blogID, folder, callback) {
debug("Synchronizing source folder with Blot");
synchronize(blogID, folder, function(err) {
if (err) return callback(err);
debug("Watching source folder for changes");
watch(blogID, folder);

if (config.environment === 'development') {
debug("Watching source folder for changes");
watch(blogID, folder);
}

debug("Setup complete");
callback();
});
Expand Down

0 comments on commit 90bcd5f

Please sign in to comment.