mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 02:35:49 +00:00
feature(cloudcmd) show line number when config is not valid json (closes #98)
This commit is contained in:
parent
9da829723d
commit
e7c5830c48
3 changed files with 17 additions and 6 deletions
|
|
@ -151,13 +151,18 @@ function readConfig(name) {
|
|||
if (!name)
|
||||
return;
|
||||
|
||||
const fs = require('fs');
|
||||
const tryCatch = require('try-catch');
|
||||
const readjson = require('readjson');
|
||||
const jju = require('jju');
|
||||
|
||||
const readjsonSync = (name) => jju.parse(fs.readFileSync(name, 'utf8'), {
|
||||
mode: 'json'
|
||||
});
|
||||
|
||||
let data;
|
||||
|
||||
const error = tryCatch(() => {
|
||||
data = readjson.sync(name);
|
||||
data = readjsonSync(name);
|
||||
});
|
||||
|
||||
if (error)
|
||||
|
|
|
|||
|
|
@ -112,6 +112,7 @@
|
|||
"http-auth": "^2.3.1",
|
||||
"ishtar": "^1.5.0",
|
||||
"jaguar": "^3.0.0",
|
||||
"jju": "^1.3.0",
|
||||
"join-io": "^1.4.0",
|
||||
"jonny": "^1.0.0",
|
||||
"markdown-it": "^8.0.0",
|
||||
|
|
@ -125,7 +126,6 @@
|
|||
"package-json": "^2.3.0",
|
||||
"ponse": "^1.4.0",
|
||||
"pullout": "^1.0.1",
|
||||
"readjson": "^1.1.0",
|
||||
"remedy": "^1.5.0",
|
||||
"rendy": "^1.1.0",
|
||||
"restafary": "^1.6.0",
|
||||
|
|
@ -153,6 +153,7 @@
|
|||
"nsp": "^2.2.1",
|
||||
"nyc": "^9.0.1",
|
||||
"place": "^1.1.4",
|
||||
"readjson": "^1.1.3",
|
||||
"recess": "^1.1.9",
|
||||
"redrun": "^5.0.0",
|
||||
"request": "^2.76.0",
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ const DIR_COMMON = DIR_SERVER + '../common/';
|
|||
const DIR = DIR_SERVER + '../';
|
||||
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
|
||||
const exit = require(DIR_SERVER + 'exit');
|
||||
const CloudFunc = require(DIR_COMMON + 'cloudfunc');
|
||||
|
|
@ -12,7 +13,7 @@ const CloudFunc = require(DIR_COMMON + 'cloudfunc');
|
|||
const pullout = require('pullout/legacy');
|
||||
const ponse = require('ponse');
|
||||
const jonny = require('jonny');
|
||||
const readjson = require('readjson');
|
||||
const jju = require('jju');
|
||||
const writejson = require('writejson');
|
||||
const tryCatch = require('try-catch');
|
||||
const exec = require('execon');
|
||||
|
|
@ -24,9 +25,13 @@ const apiURL = CloudFunc.apiURL;
|
|||
const ConfigPath = path.join(DIR, 'json/config.json');
|
||||
const ConfigHome = path.join(HOME, '.cloudcmd.json');
|
||||
|
||||
const readjsonSync = (name) => jju.parse(fs.readFileSync(name, 'utf8'), {
|
||||
mode: 'json'
|
||||
});
|
||||
|
||||
let config;
|
||||
let error = tryCatch(() => {
|
||||
config = readjson.sync(ConfigHome);
|
||||
config = readjsonSync(ConfigHome);
|
||||
});
|
||||
|
||||
if (error) {
|
||||
|
|
@ -34,7 +39,7 @@ if (error) {
|
|||
console.error('cloudcmd --config ~/.cloudcmd.json:', error.message);
|
||||
|
||||
error = tryCatch(() => {
|
||||
config = readjson.sync(ConfigPath);
|
||||
config = readjsonSync(ConfigPath);
|
||||
});
|
||||
|
||||
if (error)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue