mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-08-22 05:07:05 +00:00
Rework logging colors (#3350)
- Replacing old package `colors` by drop-in replacement `ansis`
- Rework `console-stamp` config to show all Log outputs in same color
(errors = red, warnings = yellow, debug = blue background (only for the
label), info = blue)
- This also fixes `npm run config:check` (broken since
6097547c10
)
Feel free to let me know if the PR is too big and you want me to do
individual PRs for the changes.
Before:

After:

---------
Co-authored-by: Veeck <github@veeck.de>
This commit is contained in:
committed by
GitHub
parent
098757f248
commit
6dbacbb773
@@ -1,38 +1,7 @@
|
||||
const colors = require("colors/safe");
|
||||
const Utils = require("../../../js/utils");
|
||||
|
||||
describe("Utils", () => {
|
||||
describe("colors", () => {
|
||||
const colorsEnabled = colors.enabled;
|
||||
|
||||
afterEach(() => {
|
||||
colors.enabled = colorsEnabled;
|
||||
});
|
||||
|
||||
it("should have info, warn and error properties", () => {
|
||||
expect(Utils.colors).toHaveProperty("info");
|
||||
expect(Utils.colors).toHaveProperty("warn");
|
||||
expect(Utils.colors).toHaveProperty("error");
|
||||
});
|
||||
|
||||
it("properties should be functions", () => {
|
||||
expect(typeof Utils.colors.info).toBe("function");
|
||||
expect(typeof Utils.colors.warn).toBe("function");
|
||||
expect(typeof Utils.colors.error).toBe("function");
|
||||
});
|
||||
|
||||
it("should print colored message in supported consoles", () => {
|
||||
colors.enabled = true;
|
||||
expect(Utils.colors.info("some informations")).toBe("\u001b[34msome informations\u001b[39m");
|
||||
expect(Utils.colors.warn("a warning")).toBe("\u001b[33ma warning\u001b[39m");
|
||||
expect(Utils.colors.error("ERROR!")).toBe("\u001b[31mERROR!\u001b[39m");
|
||||
});
|
||||
|
||||
it("should print message in unsupported consoles", () => {
|
||||
colors.enabled = false;
|
||||
expect(Utils.colors.info("some informations")).toBe("some informations");
|
||||
expect(Utils.colors.warn("a warning")).toBe("a warning");
|
||||
expect(Utils.colors.error("ERROR!")).toBe("ERROR!");
|
||||
});
|
||||
it("should output system information", async () => {
|
||||
await expect(Utils.logSystemInformation()).resolves.toContain("platform: linux");
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user