-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(console): inline colors and drop
chalk
(#3043)
- Loading branch information
Showing
6 changed files
with
21 additions
and
27 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@rnx-kit/console": patch | ||
--- | ||
|
||
Inline the colors we use and drop `chalk` |
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,12 +1,21 @@ | ||
import chalk from "chalk"; | ||
import { WriteStream } from "tty"; | ||
|
||
type Log = typeof console.log; | ||
|
||
export const error: Log = (...args) => | ||
console.error(chalk.red.bold("error"), ...args); | ||
let errorTag: string; | ||
let infoTag: string; | ||
let warnTag: string; | ||
|
||
export const info: Log = (...args) => | ||
console.log(chalk.cyan.bold("info"), ...args); | ||
if (WriteStream.prototype.hasColors() && process.env["NODE_ENV"] !== "test") { | ||
errorTag = "\u001B[31m\u001B[1merror\u001B[22m\u001B[39m"; | ||
infoTag = "\u001B[36m\u001B[1minfo\u001B[22m\u001B[39m"; | ||
warnTag = "\u001B[33m\u001B[1mwarn\u001B[22m\u001B[39m"; | ||
} else { | ||
errorTag = "error"; | ||
infoTag = "info"; | ||
warnTag = "warn"; | ||
} | ||
|
||
export const warn: Log = (...args) => | ||
console.warn(chalk.yellow.bold("warn"), ...args); | ||
export const error: Log = (...args) => console.error(errorTag, ...args); | ||
export const info: Log = (...args) => console.log(infoTag, ...args); | ||
export const warn: Log = (...args) => console.warn(warnTag, ...args); |
This file was deleted.
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