#100DaysOfMERN - Day 4

#100DaysOfMERN - Day 4

·

3 min read

✏ npx and cows

Today I went through the documentation about npx and was introduced to a cute little package called cowsay. It basically just prints a configurable cow in your console:

 ________________
< HAPPY NEW YEAR >
 ----------------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||

You can spawn it with:

npx cowsay WHAT

I already met npx yesterday when installing webpack. It is a package runner that gives you "installation-less command execution", so you don't have to install cowsay locally in your project. In other words, you can move to any folder in your terminal and let the cow talk.

Just for fun, you can configure your cow by adding flags (-e for the eyes and -T for the tongue). See a full list of options with npx cowsay -h.

 _______________________
< SALAD IS GOOD FOR YOU >
 -----------------------
        \   ^__^
         \  (OO)\_______
            (__)\       )\/\
                ||----w |
                ||     ||

I actually meant to write a lot more about npx, but fell into a rabbit hole when I read through the documentation on npmjs.com and came across an example using a package called lolcatjs. You can use it to give your cow rainbow colours:

lolcatjs-cowsay.jpg

The command to do so:

npx -p lolcatjs -p cowsay -c 'echo "I_AM_A_UNICORN" | cowsay | lolcatjs'
 ______________________
< STOP PROCRASTINATING >
 ----------------------
        \   ^__^
         \  (==)\_______
            (__)\       )\/\
                ||----w |
                ||     ||

✏ Recap

I've learned

  • how to print a speaking cow into the console
  • how to make that cow rainbow-coloured

✏ Next:

  • (still) more about npx
  • semantic versioning

✏ Thanks for reading!

I do my best to thoroughly research the things I learn, but if you find any errors or have additions, please leave a comment below, or @ me on Twitter. If you liked this post, I invite you to subsribe to my newsletter. Until next time 👋