Skip to content

Instantly share code, notes, and snippets.

@RoboSparrow
Last active June 17, 2022 17:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save RoboSparrow/e9973cf37eac7c89eb52cda64bf370f3 to your computer and use it in GitHub Desktop.
Save RoboSparrow/e9973cf37eac7c89eb52cda64bf370f3 to your computer and use it in GitHub Desktop.
Simple node colors
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;
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