Skip to content

Commit 485378d

Browse files
author
zhangbiaoguang
committed
fixed the bug on windows: SyntaxError-Unexpected end of input
1 parent 6e75107 commit 485378d

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/cli/run.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,14 @@ module.exports = function (argv) {
188188
const watchedFile = path.resolve(watchedDir, file)
189189
if (watchedFile === path.resolve(source)) {
190190
if (is.JSON(watchedFile)) {
191-
var obj = JSON.parse(fs.readFileSync(watchedFile))
191+
var obj = null;
192+
try {
193+
obj = JSON.parse(fs.readFileSync(watchedFile));
194+
} catch (e) {
195+
console.log('The format of the json file is not right, please check.');
196+
console.dir(e);
197+
return;
198+
}
192199
// Compare .json file content with in memory database
193200
var isDatabaseDifferent = !_.isEqual(obj, app.db.getState())
194201
if (isDatabaseDifferent) {

0 commit comments

Comments
 (0)