mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 10:45:47 +00:00
feature(config) show error.message when file exist, but could not be read from home
This commit is contained in:
parent
08ed4e6621
commit
6efbef5210
1 changed files with 20 additions and 3 deletions
|
|
@ -9,6 +9,7 @@
|
|||
path = require('path'),
|
||||
|
||||
password = require(DIR_SERVER + 'password'),
|
||||
exit = require(DIR_SERVER + 'exit'),
|
||||
Util = require(DIR_LIB + 'util'),
|
||||
CloudFunc = require(DIR_LIB + 'cloudfunc'),
|
||||
|
||||
|
|
@ -17,6 +18,7 @@
|
|||
ponse = require('ponse'),
|
||||
jonny = require('jonny'),
|
||||
readjson = require('readjson'),
|
||||
tryCatch = require('try-catch'),
|
||||
HOME = require('os-homedir')(),
|
||||
|
||||
apiURL = CloudFunc.apiURL,
|
||||
|
|
@ -24,9 +26,24 @@
|
|||
ConfigPath = path.join(DIR, 'json/config.json'),
|
||||
ConfigHome = path.join(HOME, '.cloudcmd.json'),
|
||||
|
||||
config =
|
||||
readjson.sync.try(ConfigHome) ||
|
||||
readjson.sync.try(ConfigPath);
|
||||
error,
|
||||
config;
|
||||
|
||||
error = tryCatch(function() {
|
||||
config = readjson.sync(ConfigHome);
|
||||
});
|
||||
|
||||
if (error) {
|
||||
if (error.code !== 'ENOENT')
|
||||
console.error('cloudcmd --config ~/.cloudcmd.json:', error.message);
|
||||
|
||||
error = tryCatch(function() {
|
||||
config = readjson.sync(ConfigPath);
|
||||
});
|
||||
|
||||
if (error)
|
||||
exit('cloudcmd --config', ConfigPath + ':', error.message);
|
||||
}
|
||||
|
||||
module.exports = manage;
|
||||
module.exports.save = save;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue