Skip to content

Commit

Permalink
feat: reload projects file on change
Browse files Browse the repository at this point in the history
  • Loading branch information
Kaixhin committed Oct 16, 2015
1 parent f8cb8df commit 95452d4
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,23 @@ fs.readFile("specs.json", "utf-8")
// Attempt to read existing projects
fs.readFile("projects.json", "utf-8")
.then(function(proj) {
console.log("Loaded projects");
projects = JSON.parse(proj || "{}");
})
.catch(function() {
projects = {};
});

// Reload file on change
fs.watch("projects.json", function() {
fs.readFile("projects.json", "utf-8")
.then(function(proj) {
console.log("Reloaded projects");
projects = JSON.parse(proj || "{}");
})
});


/* Global max capacity */
var maxCapacity = 1;

Expand Down

0 comments on commit 95452d4

Please sign in to comment.