mirror of https://github.com/embarklabs/embark.git
better errors when parsing invalid json
This commit is contained in:
parent
ee43f58c15
commit
bc34e00268
|
@ -1,5 +1,7 @@
|
|||
const parseJson = require('parse-json');
|
||||
let fs = require('fs-extra');
|
||||
let utils = require('../utils/utils.js');
|
||||
require('colors');
|
||||
|
||||
function mkdirpSync() {
|
||||
return fs.mkdirpSync.apply(fs.mkdirpSync, arguments);
|
||||
|
@ -18,7 +20,13 @@ function readFileSync() {
|
|||
}
|
||||
|
||||
function readJSONSync() {
|
||||
return fs.readJSONSync.apply(fs.readJSONSync, arguments);
|
||||
let content = readFileSync.apply(readFileSync, arguments);
|
||||
try {
|
||||
return parseJson(content);
|
||||
} catch(e) {
|
||||
console.error("error: ".red + arguments[0].green.underline + " " + e.message.green);
|
||||
process.exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
function writeJSONSync() {
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
"merge": "^1.2.0",
|
||||
"mocha": "^2.2.5",
|
||||
"orbit-db": "^0.17.3",
|
||||
"parse-json": "^4.0.0",
|
||||
"promptly": "^2.1.0",
|
||||
"serve-static": "^1.11.1",
|
||||
"shelljs": "^0.5.0",
|
||||
|
|
Loading…
Reference in New Issue