diff options
author | Samy Pessé <samypesse@gmail.com> | 2014-04-04 10:55:48 -0700 |
---|---|---|
committer | Samy Pessé <samypesse@gmail.com> | 2014-04-04 10:55:48 -0700 |
commit | 5cae311edf62e5c86edd9083a8d927730710c2f9 (patch) | |
tree | 5bf316fdffe9bc38d27f453bf38ab8b35e13b364 /bin/gitbook.js | |
parent | 26701a2a73a6ea82d350123458b0ba42bfe7d897 (diff) | |
download | gitbook-5cae311edf62e5c86edd9083a8d927730710c2f9.zip gitbook-5cae311edf62e5c86edd9083a8d927730710c2f9.tar.gz gitbook-5cae311edf62e5c86edd9083a8d927730710c2f9.tar.bz2 |
Log error in command line tool
Diffstat (limited to 'bin/gitbook.js')
-rwxr-xr-x | bin/gitbook.js | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/bin/gitbook.js b/bin/gitbook.js index d57e785..3abeafd 100755 --- a/bin/gitbook.js +++ b/bin/gitbook.js @@ -1,6 +1,7 @@ #! /usr/bin/env node // Requires +var Q = require('q'); var _ = require('lodash'); var path = require('path'); var prog = require('commander'); @@ -14,6 +15,10 @@ var generators = require("../lib/generate").generators; var utils = require('./utils'); +var logError = function(err) { + console.log(err.message || err); + return Q.reject(err); +}; // General options prog @@ -69,9 +74,7 @@ prog }) .then(function(output) { console.log("Successfuly built !"); - }, function(err) { - throw err; - }) + }, logError) .then(_.constant(outputDir)); }); @@ -88,15 +91,13 @@ prog .then(function(outputDir) { console.log(); console.log('Starting server ...'); - return utils.serveDir(outputDir, options.port); + return utils.serveDir(outputDir, options.port) + .fail(logError); }) .then(function() { console.log('Serving book on http://localhost:'+options.port); console.log(); console.log('Press CTRL+C to quit ...'); - }) - .fail(function(err) { - console.error(err); }); }); |