Fix overriding home folder
This commit is contained in:
parent
d725bf0f70
commit
dcec9f3c37
@ -12,9 +12,8 @@ program.option("");
|
|||||||
program.option(" --home <path>" , "home path");
|
program.option(" --home <path>" , "home path");
|
||||||
|
|
||||||
var argv = program.parseOptions(process.argv);
|
var argv = program.parseOptions(process.argv);
|
||||||
if (program.home) {
|
|
||||||
Helper.HOME = path.resolve(program.home);
|
Helper.setHome(program.home);
|
||||||
}
|
|
||||||
|
|
||||||
if (!fs.existsSync(Helper.CONFIG_PATH)) {
|
if (!fs.existsSync(Helper.CONFIG_PATH)) {
|
||||||
mkdirp.sync(Helper.HOME, {mode: "0700"});
|
mkdirp.sync(Helper.HOME, {mode: "0700"});
|
||||||
|
@ -1,17 +1,21 @@
|
|||||||
var path = require("path");
|
var path = require("path");
|
||||||
var os = require("os");
|
var os = require("os");
|
||||||
|
|
||||||
var HOME = expandHome("~/.lounge");
|
var Helper = {
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
HOME: HOME,
|
|
||||||
CONFIG_PATH: path.join(HOME, "config.js"),
|
|
||||||
USERS_PATH: path.join(HOME, "users"),
|
|
||||||
expandHome: expandHome,
|
expandHome: expandHome,
|
||||||
getConfig: getConfig,
|
getConfig: getConfig,
|
||||||
getUserConfigPath: getUserConfigPath,
|
getUserConfigPath: getUserConfigPath,
|
||||||
|
setHome: setHome,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
module.exports = Helper;
|
||||||
|
|
||||||
|
function setHome(homePath) {
|
||||||
|
this.HOME = expandHome(homePath || "~/.lounge");
|
||||||
|
this.CONFIG_PATH = path.join(this.HOME, "config.js");
|
||||||
|
this.USERS_PATH = path.join(this.HOME, "users");
|
||||||
|
}
|
||||||
|
|
||||||
function getUserConfigPath(name) {
|
function getUserConfigPath(name) {
|
||||||
return path.join(this.USERS_PATH, name + ".json");
|
return path.join(this.USERS_PATH, name + ".json");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user