Fix missing colors dependency, simplify version warning

This commit is contained in:
Pavel Djundik 2018-11-27 13:15:01 +02:00
parent 6a4a45711b
commit 8635f2f3d8
2 changed files with 8 additions and 24 deletions

View File

@ -5,32 +5,16 @@
process.chdir(__dirname); process.chdir(__dirname);
// Perform node version check before loading any other files or modules // Perform node version check before loading any other files or modules
// Doing this check as soon as possible allows us to avoid ES6 parser errors or // Doing this check as soon as possible allows us to
// other issues // avoid ES6 parser errors or other issues
// Try to display messages nicely, but gracefully degrade if anything goes wrong
const pkg = require("./package.json"); const pkg = require("./package.json");
if (!require("semver").satisfies(process.version, pkg.engines.node)) { if (!require("semver").satisfies(process.version, pkg.engines.node)) {
let colors; /* eslint-disable no-console */
let log; console.error("The Lounge requires Node.js " + pkg.engines.node + " (current version: " + process.version + ")");
console.error("Please upgrade Node.js in order to use The Lounge");
try { console.error("See https://thelounge.chat/docs/install-and-upgrade");
colors = require("colors/safe"); console.error();
} catch (e) {
colors = {};
colors.green = colors.red = colors.bold = (x) => x;
}
try {
log = require("./src/log");
} catch (e) {
log = {};
log.error = (msg) => console.error(`[ERROR] ${msg}`); // eslint-disable-line no-console
}
log.error(`The Lounge requires Node.js ${colors.green(pkg.engines.node)} (current version: ${colors.red(process.version)})`);
log.error(colors.bold("Please upgrade Node.js in order to use The Lounge"));
log.error("See https://nodejs.org/en/download/package-manager/ for more details");
process.exit(1); process.exit(1);
} }

View File

@ -9,7 +9,7 @@
// ``` // ```
const {readFileSync, writeFileSync} = require("fs"); const {readFileSync, writeFileSync} = require("fs");
const colors = require("colors/safe"); const colors = require("chalk");
const log = require("../src/log"); const log = require("../src/log");
const {join} = require("path"); const {join} = require("path");
const {spawnSync} = require("child_process"); const {spawnSync} = require("child_process");