zurb/foundation-cli — pull request #6 by gakimball (2014-12-13 03:03:23+00:00)
Title: Upgrades: less exec, and more error handling

The CLI has been in the wild for a week now, and the main thing we've divined as the issues have come in is that the CLI needs better error handling. Here's what this update will change:

- [ ] Stop the user if they try to run a command as root (I don't know if people are doing this but it will create problems)
- [ ] Add contact and support information to the `help` command
- [x] Before setting up a new project, check if the user has the `git`, `ruby`, and `bundle` commands on their system, and output an error if any are missing
- [x] Check if a folder exists before running `git clone`
- [ ] Use npm's programmatic API instead of `exec('npm')`
- [x] Use Bower's programmatic API instead of `exec('bower')`
- [ ] When running `watch`, catch an `EADDRINUSE` error (happens if you try to run a second test server) and output a more friendly error message

There's also an issue with users whose systems are configured to require root access to use `npm` and `bundle`. That's sort of a tricky issue to work around, especially with Bundler, because it's a totally external process.

These changes need to be tested in a Windows prompt as well. Using npm and Bower's built-in APIs means two less `exec` commands (it also means the user doesn't need Bower installed on their system), so that cuts down on some cross-platform hassle. We also need to make sure the `which` command properly finds Windows shell commands (apparently it [has issues](https://github.com/isaacs/node-which/issues/9) if you run Bash in Windows, also).

It would also be *super nice* if the `new` command could somehow use promises instead of a bunch of nested callbacks, but I don't really know how those work yet ;)