-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
💄 Add chalk for some colors in logging
- Loading branch information
1 parent
310e294
commit c72d4e2
Showing
3 changed files
with
33 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,32 @@ | ||
import chalk from 'chalk'; | ||
const log = console.log; | ||
|
||
export const logAndForget = (msg: string) => { | ||
console.log(msg); | ||
log(msg); | ||
process.exit(0); | ||
}; | ||
|
||
export const info = (msg: string) => { | ||
console.log(msg); | ||
export const info = (msg: string, highlighted: boolean | string[] = []) => { | ||
let message = msg; | ||
|
||
if (typeof highlighted === 'boolean') { | ||
message = chalk.underline.blue(message); | ||
} else { | ||
for (const word of msg.replace(/[^\w\s]/gi, '').split(' ')) { | ||
if (highlighted.includes(word)) { | ||
message = message.replace(word, chalk.blue(word)); | ||
} | ||
} | ||
} | ||
|
||
log(message); | ||
}; | ||
|
||
export const warn = (msg: string) => { | ||
log(chalk.yellow(msg)); | ||
}; | ||
|
||
export const error = (msg: string) => { | ||
log(chalk.red(msg)); | ||
process.exit(1); | ||
}; |
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