chalk - Terminal string styling done right. Much color.
colors.js used to be the most popular string styling module, but it has serious deficiencies like extending String.prototype which causes all kinds of problems. Although there are other ones, they either do too much or not enough.
Chalk is a clean and focused alternative.
$ sbt clean publish-local
Before running the tests the first time, you must ensure the npm packages are installed:
$ npm install
Then you can run the tests:
$ sbt test
import io.scalajs.npm.chalk._
// style a string")
println(Chalk.blue("Hello world!"))
Hello World!
import io.scalajs.npm.chalk._
// compose multiple styles using the chainable API
println(Chalk.blue.bgRed.bold("Hello world!"))
Hello World!
import io.scalajs.npm.chalk._
// pass in multiple arguments
println(Chalk.blue("Hello", "World!", "Foo", "bar", "biz", "baz"))
Hello World! Foo bar biz baz
import io.scalajs.npm.chalk._
// nested styles
println(Chalk.red("Hello", Chalk.underline.bgBlue("World") + "!"))
Hello World!
import io.scalajs.nodejs.console
import io.scalajs.npm.chalk._
// use it like a function
val error = Chalk.bold.red
console.log(error("Error!"))
Error!
To add the Chalk
binding to your project, add the following to your build.sbt:
libraryDependencies += "io.scalajs.npm" %%% "chalk" % "0.5.0"
Optionally, you may add the Sonatype Repository resolver:
resolvers += Resolver.sonatypeRepo("releases")