Last active
June 17, 2022 17:14
-
-
Save RoboSparrow/e9973cf37eac7c89eb52cda64bf370f3 to your computer and use it in GitHub Desktop.
Simple node colors
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
const colors = { | |
green: text => `\x1b[32m${text}\x1b[0m`, | |
red: text => `\x1b[31m${text}\x1b[0m`, | |
yellow: text => `\x1b[33m${text}\x1b[0m`, | |
blue: text => `\x1b[34m${text}\x1b[0m`, | |
}; | |
module.exports = colors; |
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
const colors = require ('./colors'); | |
console.log(` | |
Lorem ipsum dolor ${colors.red('sit amet')}, consectetur adipiscing elit, ${colors.blue('sed do eiusmod tempor')} incididunt ut labore et dolore magna aliqua. | |
Ut enim ad minim veniam, quis ${colors.green('nostrud exercitation')} ullamco laboris nisi ut aliquip ex ea ${colors.yellow('commodo consequa')}. | |
`); | |
console.log(colors.green('Success: ') + 'success message'); | |
console.log(colors.red('Error ') + 'error message'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment