Read default LOUNGE_HOME from .lounge_home file
This commit is contained in:
parent
98bfe349d9
commit
ac3ce74343
@ -23,14 +23,7 @@ if (program.home) {
|
||||
let home = program.home || process.env.LOUNGE_HOME;
|
||||
|
||||
if (!home) {
|
||||
const distConfig = path.resolve(path.join(
|
||||
__dirname,
|
||||
"..",
|
||||
"..",
|
||||
".lounge_home"
|
||||
));
|
||||
|
||||
home = fs.readFileSync(distConfig, "utf-8").trim();
|
||||
home = Utils.defaultLoungeHome();
|
||||
}
|
||||
|
||||
Helper.setHome(home);
|
||||
|
@ -1,6 +1,10 @@
|
||||
"use strict";
|
||||
|
||||
const colors = require("colors/safe");
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
|
||||
let loungeHome;
|
||||
|
||||
class Utils {
|
||||
static extraHelp() {
|
||||
@ -9,10 +13,26 @@ class Utils {
|
||||
"",
|
||||
" Environment variable:",
|
||||
"",
|
||||
` LOUNGE_HOME Path for all configuration files and folders. Defaults to ${colors.green("~/.lounge")}.`,
|
||||
` LOUNGE_HOME Path for all configuration files and folders. Defaults to ${colors.green(Utils.defaultLoungeHome())}.`,
|
||||
"",
|
||||
].forEach((e) => console.log(e));
|
||||
}
|
||||
|
||||
static defaultLoungeHome() {
|
||||
if (loungeHome) {
|
||||
return loungeHome;
|
||||
}
|
||||
const distConfig = path.resolve(path.join(
|
||||
__dirname,
|
||||
"..",
|
||||
"..",
|
||||
".lounge_home"
|
||||
));
|
||||
|
||||
loungeHome = fs.readFileSync(distConfig, "utf-8").trim();
|
||||
|
||||
return loungeHome;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Utils;
|
||||
|
Loading…
Reference in New Issue
Block a user