Skip to content

Instantly share code, notes, and snippets.

@khalidx
Created June 25, 2020 16:34
Show Gist options
  • Save khalidx/a8f4172f3bb19f591054b63d74d57919 to your computer and use it in GitHub Desktop.
Save khalidx/a8f4172f3bb19f591054b63d74d57919 to your computer and use it in GitHub Desktop.
Shows a banner on the CLI using a cool font

banner

Shows a banner on the CLI using a cool font.

For NodeJs & TypeScript. Depends on the amazing figlet and chalk libraries.

import figlet from 'figlet'
import chalk from 'chalk'

/**
 * Clears the console and shows the banner
 */
async function showBanner (): Promise<void> {
  return new Promise(function (resolve, reject) {
    process.stdout.write('\x1b[2J')
    process.stdout.write('\x1b[0f')
    figlet.text('the banner', function (error, result) {
      if (error) reject(error)
      else {
        console.log(chalk.blue(result))
        resolve()
      }
    })
  })
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment