Don't crash in case of bad json

parent 3ec76302
...@@ -48,14 +48,17 @@ module.exports = function (urls) { ...@@ -48,14 +48,17 @@ module.exports = function (urls) {
urlsFile = urls, urlsFile = urls,
urls = JSON.parse(fs.readFileSync(urlsFile)); urls = JSON.parse(fs.readFileSync(urlsFile));
fs.watchFile(urlsFile, function () { fs.watchFile(urlsFile, function () {
var self = this;
console.log("Reloading urls..."); console.log("Reloading urls...");
fs.readFile(urlsFile, function (err, data) { fs.readFile(urlsFile, function (err, data) {
if (err) { if (!err) {
self.emit('error', err); try {
}
urls = JSON.parse(data); urls = JSON.parse(data);
matchers = getMatchers(urls); matchers = getMatchers(urls);
}
catch (e) {
console.log("Syntax error in json file.");
}
}
}); });
}); });
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment