mirror of
https://github.com/thelounge/thelounge
synced 2024-11-22 20:13:07 +00:00
Merge pull request #2907 from thelounge/xpaw/fix-colors
Fix missing colors dependency, simplify version warning
This commit is contained in:
commit
0e4eb4e269
2 changed files with 8 additions and 24 deletions
30
index.js
30
index.js
|
@ -5,32 +5,16 @@
|
|||
process.chdir(__dirname);
|
||||
|
||||
// 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
|
||||
// other issues
|
||||
// Try to display messages nicely, but gracefully degrade if anything goes wrong
|
||||
// Doing this check as soon as possible allows us to
|
||||
// avoid ES6 parser errors or other issues
|
||||
const pkg = require("./package.json");
|
||||
|
||||
if (!require("semver").satisfies(process.version, pkg.engines.node)) {
|
||||
let colors;
|
||||
let log;
|
||||
|
||||
try {
|
||||
colors = require("colors/safe");
|
||||
} 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");
|
||||
/* eslint-disable no-console */
|
||||
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");
|
||||
console.error("See https://thelounge.chat/docs/install-and-upgrade");
|
||||
console.error();
|
||||
|
||||
process.exit(1);
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
// ```
|
||||
|
||||
const {readFileSync, writeFileSync} = require("fs");
|
||||
const colors = require("colors/safe");
|
||||
const colors = require("chalk");
|
||||
const log = require("../src/log");
|
||||
const {join} = require("path");
|
||||
const {spawnSync} = require("child_process");
|
||||
|
|
Loading…
Reference in a new issue