Merge pull request #1416 from thelounge/xpaw/handle-distro-configs

Use .lounge_config to help distribution packages handle config paths right
This commit is contained in:
Jérémie Astori 2017-08-15 20:11:38 -04:00 committed by GitHub
commit f93634df39
3 changed files with 21 additions and 2 deletions

1
.lounge_config Normal file
View file

@ -0,0 +1 @@
~/.lounge

View file

@ -13,7 +13,25 @@ program.version(Helper.getVersion(), "-v, --version")
.option("--home <path>", "path to configuration folder")
.parseOptions(process.argv);
Helper.setHome(program.home || process.env.LOUNGE_HOME);
if (program.home) {
log.warn(`${colors.green("--home")} is deprecated and will be removed in a future version.`);
log.warn(`Use ${colors.green("LOUNGE_HOME")} environment variable instead.`);
}
let home = program.home || process.env.LOUNGE_HOME;
if (!home) {
const distConfig = path.resolve(path.join(
__dirname,
"..",
"..",
".lounge_config"
));
home = fs.readFileSync(distConfig, "utf-8").trim();
}
Helper.setHome(home);
if (!fs.existsSync(Helper.CONFIG_PATH)) {
fsextra.ensureDirSync(Helper.HOME);

View file

@ -60,7 +60,7 @@ function getGitCommit() {
}
function setHome(homePath) {
this.HOME = expandHome(homePath || "~/.lounge");
this.HOME = expandHome(homePath);
this.CONFIG_PATH = path.join(this.HOME, "config.js");
this.USERS_PATH = path.join(this.HOME, "users");