thelounge/src/command-line/utils.js
Jérémie Astori 052248445c
Do not rename home file as it is very likely to have permission issues
On most systems (Linux at least), to install a npm package locally, one must use `sudo`. When The Lounge runs, it usually does not run with `sudo`. This causes the program to crash as user running The Lounge cannot create/delete files there.

We will let people manually convert this file instead of doing it for them. This file is mainly intended for package authors anyway, most users will never have to touch it.
2017-12-01 01:33:04 -05:00

56 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;
}
let distConfig;
// 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(`Use ${colors.green(".thelounge_home")} instead.`);
distConfig = deprecatedDistConfig;
} else {
distConfig = path.resolve(path.join(
__dirname,
"..",
"..",
".thelounge_home"
));
}
home = fs.readFileSync(distConfig, "utf-8").trim();
return home;
}
}
module.exports = Utils;