12. Command-Line Programming

After spending so much time in this book discussing how Node.js is a powerful asynchronous, nonblocking platform for creating applications, I’m now going to show you how sometimes using regular synchronous, blocking IO is also cool in Node—writing command-line programs. It turns out that writing JavaScript code is so much fun that people are starting to write a lot of their day-to-day scripts and other quick programs in Node as well.

In this chapter, you look at the basics of running command-line scripts in Node, including looking at some of the synchronous file system APIs available to you. You then look at how you can interact with the user directly via buffered and unbuffered input, and finally look at process ...

Get Learning Node.js, Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.