From 485378d22203778f839e4f3ff66072d4d6f157b6 Mon Sep 17 00:00:00 2001 From: zhangbiaoguang Date: Tue, 29 Nov 2016 18:55:30 +0800 Subject: [PATCH] fixed the bug on windows: SyntaxError-Unexpected end of input --- src/cli/run.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/cli/run.js b/src/cli/run.js index 648974c2d..ebdbd2c05 100644 --- a/src/cli/run.js +++ b/src/cli/run.js @@ -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) {