Tag Archives: ShellJS

Commanding the CLI with Node

via Commanding the CLI with Node – Craftsy Engineering Blog.

Prior to Node v0.12, writing a command line tool in Node was a rather difficult proposition. There was no way to execute a command synchronously, so tools like ShellJS worked around this by blocking the event loop until a ‘done’ file was created on the filesystem signifying that the command was complete. Thankfully, Node v0.12 introduces the long-awaited child_process.execSync()method. Behind the scenes it uses its own event loop for each launched process and watches for the SIGCHLD signal to indicate that the process is done, but all of this is smoothly handled for you so all you need to care about is that Node can finally execute commands synchronously.