forked from MagicMirrorOrg/MagicMirror
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rework logging colors (MagicMirrorOrg#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 6097547) Feel free to let me know if the PR is too big and you want me to do individual PRs for the changes. Before: ![before](https://github.com/MagicMirrorOrg/MagicMirror/assets/35647502/88e48ec3-102c-40f3-9e9b-5d14fe446a43) After: ![after](https://github.com/MagicMirrorOrg/MagicMirror/assets/35647502/4c8c4bad-08c9-46a3-92c9-14b996c13a7d) --------- Co-authored-by: Veeck <github@veeck.de>
- Loading branch information
1 parent
098757f
commit 6dbacbb
Showing
9 changed files
with
62 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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"); | ||
}); | ||
}); |