mirror of
https://github.com/thelounge/thelounge.git
synced 2024-05-13 03:36:56 +02:00
827f1dab96
This is one more step towards uniformization of lounge/thelounge due with The Lounge v3.
54 lines
1.1 KiB
JavaScript
54 lines
1.1 KiB
JavaScript
"use strict";
|
|
|
|
const colors = require("colors/safe");
|
|
const fs = require("fs");
|
|
const path = require("path");
|
|
|
|
let home;
|
|
|
|
class Utils {
|
|
static extraHelp() {
|
|
[
|
|
"",
|
|
"",
|
|
" Environment variable:",
|
|
"",
|
|
` 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 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.`);
|
|
|
|
fs.renameSync(deprecatedDistConfig, distConfig);
|
|
}
|
|
|
|
home = fs.readFileSync(distConfig, "utf-8").trim();
|
|
|
|
return home;
|
|
}
|
|
}
|
|
|
|
module.exports = Utils;
|