Financial-Times/origami-build-tools — pull request #51 by samgiles (2014-08-06 13:31:37+00:00)
Title:  Improve debug output

This commit primarily tries to start using error handling in the callbacks in the correct node convention `cb(err, result)`, now if an install task fails a message directly from the failing tool is displayed. Additionally this commit ensures that the correct `node_modules` directory is used when looking up commands.

Realistically there is more to do for issue #3, as work is done, we should mindfully include thoughts and code related to helpful error handling and typical Node error conventions

- Remove logging on stdout. This could get interleaved with other processes emitting data into their respective stdout file descriptor while everything is passed to console.log on data receive. Buffering allows more control over the output and display of error messages.

- On process close, if the return value was not 0, add the error code to the output information for the process and call the callback with an error argument. If the return value is 0 then call the callback with a null error argument and a normal result argument containing stderr and stdout

- Remove unnecessary nextTicks and fix bug where the callback was called twice in command-line.js

- Ensure the correct JSHint command is selected based on the location of the
node_modules directory and ensure the correct callback convention is used (err, result) consistently.
Move the getNodeModules directory function into files for resuse across commands.
Now used in install to get the path to the install location for npm managed packages.
And used to find the correct executable installed by npm for jshint in the verify command.

- In order to correctly output the http-server process output to stdout, use spawn and pipe to process.stdout

I broke the granular commit rule because I rebase -> squashed them because they were a bit all over the place. :( Sorry.