mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-24 03:05:41 +00:00
feature(config) default path: ~/.cloudcmd.json
This commit is contained in:
parent
46f283fb4e
commit
1f7a41ced1
2 changed files with 38 additions and 43 deletions
|
|
@ -5,14 +5,23 @@
|
|||
DIR_LIB = DIR_SERVER + '../',
|
||||
DIR = DIR_SERVER + '../../',
|
||||
|
||||
HOME_WIN = process.env.HOMEPATH,
|
||||
HOME_UNIX = process.env.HOME,
|
||||
|
||||
HOME = (HOME_UNIX || HOME_WIN) + '/',
|
||||
|
||||
|
||||
fs = require('fs'),
|
||||
|
||||
Util = require(DIR_LIB + 'util'),
|
||||
tryRequire = require(DIR_SERVER + 'tryRequire'),
|
||||
|
||||
ConfigPath = DIR + 'json/config.json',
|
||||
ConfigPath = DIR + 'json/config.json',
|
||||
ConfigHome = HOME + '.cloudcmd.json',
|
||||
|
||||
config = tryRequire(ConfigPath, {log: true}) || {};
|
||||
config =
|
||||
tryRequire(ConfigHome) ||
|
||||
tryRequire(ConfigPath, {log: true}) || {};
|
||||
|
||||
module.exports = function(key, value) {
|
||||
var result;
|
||||
|
|
@ -31,7 +40,7 @@
|
|||
Util.checkArgs(arguments, ['callback']);
|
||||
|
||||
if (data)
|
||||
fs.writeFile(ConfigPath, data, callback);
|
||||
fs.writeFile(ConfigHome, data, callback);
|
||||
else
|
||||
callback({
|
||||
message: 'Error: config is empty!'
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue