summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron O'Mullan <aaron.omullan@friendco.de>2014-06-17 10:46:56 -0700
committerAaron O'Mullan <aaron.omullan@friendco.de>2014-06-17 10:46:56 -0700
commit80aac7f58129e028adce30bee2e64f7a39f4d843 (patch)
tree3a21ebc004c1af7a5889d2812ca22eaedfa29bcb
parent266f7ca73d0eeeb48d657bef625d2e00acd3d43a (diff)
downloadgitbook-80aac7f58129e028adce30bee2e64f7a39f4d843.zip
gitbook-80aac7f58129e028adce30bee2e64f7a39f4d843.tar.gz
gitbook-80aac7f58129e028adce30bee2e64f7a39f4d843.tar.bz2
Support --verbose flag, fixes #325
-rw-r--r--bin/build.js16
1 files changed, 13 insertions, 3 deletions
diff --git a/bin/build.js b/bin/build.js
index 4bb6bb4..965a211 100644
--- a/bin/build.js
+++ b/bin/build.js
@@ -10,9 +10,10 @@ var generators = require("../lib/generate").generators;
var buildCommand = function(command) {
return command
+ .option('-v, --verbose', 'Activate verbose mode, useful for debugging errors')
.option('-o, --output <directory>', 'Path to output directory, defaults to ./_book')
.option('-f, --format <name>', 'Change generation format, defaults to site, availables are: '+_.keys(generators).join(", "))
- .option('--config <config file>', 'Configuration file to use, defaults to book.js or book.json')
+ .option('--config <config file>', 'Configuration file to use, defaults to book.js or book.json');
};
@@ -26,6 +27,11 @@ var makeBuildFunc = function(converter) {
dir = dir || process.cwd();
outputDir = options.output;
+ // Set debugging
+ if(options.verbose) {
+ process.env.DEBUG = "true";
+ }
+
console.log('Starting build ...');
return converter(
_.extend({}, options || {}, {
@@ -38,8 +44,12 @@ var makeBuildFunc = function(converter) {
.then(function(output) {
console.log("Successfully built!");
return output;
- }, utils.logError)
- .fail(function() {
+ })
+ .fail(function(err) {
+ // Log error
+ utils.logError(err);
+
+ // Exit process with failure code
process.exit(-1);
});
};