From 5299d976c0f10a571b706aca2ad17e30c84cc129 Mon Sep 17 00:00:00 2001 From: Pavel Djundik Date: Tue, 15 Aug 2017 21:57:47 +0300 Subject: [PATCH] Use .lounge_config to help distribution packages handle config paths right --- .lounge_config | 1 + src/command-line/index.js | 20 +++++++++++++++++++- src/helper.js | 2 +- 3 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 .lounge_config diff --git a/.lounge_config b/.lounge_config new file mode 100644 index 00000000..86428c50 --- /dev/null +++ b/.lounge_config @@ -0,0 +1 @@ +~/.lounge diff --git a/src/command-line/index.js b/src/command-line/index.js index 36633c28..860a2572 100644 --- a/src/command-line/index.js +++ b/src/command-line/index.js @@ -13,7 +13,25 @@ program.version(Helper.getVersion(), "-v, --version") .option("--home ", "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); diff --git a/src/helper.js b/src/helper.js index 2fae848e..127f0f38 100644 --- a/src/helper.js +++ b/src/helper.js @@ -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");