Deprecate LOUNGE_HOME env var in favor of THELOUNGE_HOME, .lounge_home file in favor of .thelounge_home
This is one more step towards uniformization of lounge/thelounge due with The Lounge v3.
This commit is contained in:
parent
489bb8e395
commit
827f1dab96
@ -2,9 +2,9 @@
|
||||
# npm-debug.log and node_modules/ are ignored by default.
|
||||
# See https://docs.npmjs.com/misc/developers#keeping-files-out-of-your-package
|
||||
|
||||
# Ignore all dot files except for .lounge_home
|
||||
# Ignore all dot files except for .thelounge_home
|
||||
.*
|
||||
!.lounge_home
|
||||
!.thelounge_home
|
||||
|
||||
# Ignore client folder as it's being built into public/ folder
|
||||
# except for the specified files which are used by the server
|
||||
|
@ -76,7 +76,7 @@ module.exports = {
|
||||
// which in result fixes mixed content warnings.
|
||||
//
|
||||
// If storage is enabled, The Lounge will fetch and store images and thumbnails
|
||||
// in the `${LOUNGE_HOME}/storage` folder.
|
||||
// in the `${THELOUNGE_HOME}/storage` folder.
|
||||
//
|
||||
// Images are deleted when they are no longer referenced by any message (controlled by maxHistory),
|
||||
// and the folder is cleaned up on every The Lounge restart.
|
||||
|
@ -15,13 +15,13 @@ if (require("semver").lt(process.version, "6.0.0")) {
|
||||
}
|
||||
|
||||
program.version(Helper.getVersion(), "-v, --version")
|
||||
.option("--home <path>", `${colors.bold("[DEPRECATED]")} Use the ${colors.green("LOUNGE_HOME")} environment variable instead.`)
|
||||
.option("--home <path>", `${colors.bold("[DEPRECATED]")} Use the ${colors.green("THELOUNGE_HOME")} environment variable instead.`)
|
||||
.on("--help", Utils.extraHelp)
|
||||
.parseOptions(process.argv);
|
||||
|
||||
if (program.home) {
|
||||
log.warn(`${colors.green("--home")} is ${colors.bold("deprecated")} and will be removed in The Lounge v3.`);
|
||||
log.warn(`Use the ${colors.green("LOUNGE_HOME")} environment variable instead.`);
|
||||
log.warn(`Use the ${colors.green("THELOUNGE_HOME")} environment variable instead.`);
|
||||
}
|
||||
|
||||
// Check if the app was built before calling setHome as it wants to load manifest.json from the public folder
|
||||
@ -36,10 +36,15 @@ if (!fs.existsSync(path.join(
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
let home = program.home || process.env.LOUNGE_HOME;
|
||||
if (process.env.LOUNGE_HOME) {
|
||||
log.warn(`${colors.green("LOUNGE_HOME")} is ${colors.bold("deprecated")} and will be removed in The Lounge v3.`);
|
||||
log.warn(`Use ${colors.green("THELOUNGE_HOME")} instead.`);
|
||||
}
|
||||
|
||||
let home = process.env.THELOUNGE_HOME || program.home || process.env.LOUNGE_HOME;
|
||||
|
||||
if (!home) {
|
||||
home = Utils.defaultLoungeHome();
|
||||
home = Utils.defaultHome();
|
||||
}
|
||||
|
||||
Helper.setHome(home);
|
||||
|
@ -4,7 +4,7 @@ const colors = require("colors/safe");
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
|
||||
let loungeHome;
|
||||
let home;
|
||||
|
||||
class Utils {
|
||||
static extraHelp() {
|
||||
@ -13,25 +13,40 @@ class Utils {
|
||||
"",
|
||||
" Environment variable:",
|
||||
"",
|
||||
` LOUNGE_HOME Path for all configuration files and folders. Defaults to ${colors.green(Utils.defaultLoungeHome())}.`,
|
||||
` THELOUNGE_HOME Path for all configuration files and folders. Defaults to ${colors.green(Utils.defaultHome())}.`,
|
||||
"",
|
||||
].forEach((e) => console.log(e)); // eslint-disable-line no-console
|
||||
}
|
||||
|
||||
static defaultLoungeHome() {
|
||||
if (loungeHome) {
|
||||
return loungeHome;
|
||||
static defaultHome() {
|
||||
if (home) {
|
||||
return home;
|
||||
}
|
||||
|
||||
const distConfig = path.resolve(path.join(
|
||||
__dirname,
|
||||
"..",
|
||||
"..",
|
||||
".thelounge_home"
|
||||
));
|
||||
|
||||
// TODO: Remove this section when releasing The Lounge v3
|
||||
const deprecatedDistConfig = path.resolve(path.join(
|
||||
__dirname,
|
||||
"..",
|
||||
"..",
|
||||
".lounge_home"
|
||||
));
|
||||
if (fs.existsSync(deprecatedDistConfig)) {
|
||||
log.warn(`${colors.green(".lounge_home")} is ${colors.bold("deprecated")} and will be ignored as of The Lounge v3.`);
|
||||
log.warn(`Renaming to ${colors.green(".thelounge_home")} instead.`);
|
||||
|
||||
loungeHome = fs.readFileSync(distConfig, "utf-8").trim();
|
||||
fs.renameSync(deprecatedDistConfig, distConfig);
|
||||
}
|
||||
|
||||
return loungeHome;
|
||||
home = fs.readFileSync(distConfig, "utf-8").trim();
|
||||
|
||||
return home;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user