Merge pull request #2907 from thelounge/xpaw/fix-colors

Fix missing colors dependency, simplify version warning
This commit is contained in:
Pavel Djundik 2018-11-30 12:28:53 +02:00 committed by GitHub
commit 0e4eb4e269
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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");