fixed the bug on windows: SyntaxError-Unexpected end of input

This commit is contained in:
zhangbiaoguang
2016-11-29 18:55:30 +08:00
parent 6e75107638
commit 485378d222

View File

@ -188,7 +188,14 @@ module.exports = function (argv) {
const watchedFile = path.resolve(watchedDir, file)
if (watchedFile === path.resolve(source)) {
if (is.JSON(watchedFile)) {
var obj = JSON.parse(fs.readFileSync(watchedFile))
var obj = null;
try {
obj = JSON.parse(fs.readFileSync(watchedFile));
} catch (e) {
console.log('The format of the json file is not right, please check.');
console.dir(e);
return;
}
// Compare .json file content with in memory database
var isDatabaseDifferent = !_.isEqual(obj, app.db.getState())
if (isDatabaseDifferent) {