summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorSamy Pessé <samypesse@gmail.com>2014-04-06 13:44:14 -0700
committerSamy Pessé <samypesse@gmail.com>2014-04-06 13:44:14 -0700
commit014b2f9c6902235216fee390078ece0049344c0b (patch)
tree4b7a40abe74cce7b961f8a3bc63da9d4f044b315 /bin
parentfb26b634ce2f332bcc3a8764009bdc65a2245f35 (diff)
parent65cb23feabb7ae311f18c5f50978686d202dafec (diff)
downloadgitbook-014b2f9c6902235216fee390078ece0049344c0b.zip
gitbook-014b2f9c6902235216fee390078ece0049344c0b.tar.gz
gitbook-014b2f9c6902235216fee390078ece0049344c0b.tar.bz2
Merge pull request #35 from GitbookIO/feature/multilangs
Fix #34: Feature/multilangs
Diffstat (limited to 'bin')
-rwxr-xr-xbin/gitbook.js39
-rw-r--r--bin/utils.js2
2 files changed, 23 insertions, 18 deletions
diff --git a/bin/gitbook.js b/bin/gitbook.js
index 6248581..ef842fb 100755
--- a/bin/gitbook.js
+++ b/bin/gitbook.js
@@ -15,27 +15,32 @@ var buildFunc = require('./build');
// General options
prog
-.version(pkg.version)
-.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('-t, --title <name>', 'Name of the book to generate, defaults to repo name')
-.option('-i, --intro <intro>', 'Description of the book to generate')
-.option('-g, --github <repo_path>', 'ID of github repo like : username/repo')
-.option('-gh, --githubHost <url>', 'The url of the github host (defaults to https://github.com/')
-.option('--theme <path>', 'Path to theme directory');
+.version(pkg.version);
+
+var buildCommand = function(command, action) {
+ return command
+ .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('-t, --title <name>', 'Name of the book to generate, defaults to repo name')
+ .option('-i, --intro <intro>', 'Description of the book to generate')
+ .option('-g, --github <repo_path>', 'ID of github repo like : username/repo')
+ .option('-gh, --githubHost <url>', 'The url of the github host (defaults to https://github.com/')
+ .option('--theme <path>', 'Path to theme directory')
+ .action(action);
+}
var buildFunc;
-prog
+
+buildCommand(prog
.command('build [source_dir]')
-.description('Build a gitbook from a directory')
-.action();
+.description('Build a gitbook from a directory'), buildFunc);
-prog
+buildCommand(prog
.command('serve [source_dir]')
.description('Build then serve a gitbook from a directory')
-.option('-p, --port <port>', 'Port for server to listen on', 4000)
-.action(function(dir, options) {
+.option('-p, --port <port>', 'Port for server to listen on', 4000),
+function(dir, options) {
buildFunc(dir, options)
.then(function(outputDir) {
console.log();
@@ -50,11 +55,11 @@ prog
});
});
-prog
+buildCommand(prog
.command('pdf [source_dir] [output_file]')
.description('Build a gitbook as a PDF')
-.option('-pf, --paperformat <format>', 'PDF paper format (default is A4): "5in*7.5in", "10cm*20cm", "A4", "Letter"')
-.action(function(dir, outputFile, options) {
+.option('-pf, --paperformat <format>', 'PDF paper format (default is A4): "5in*7.5in", "10cm*20cm", "A4", "Letter"'),
+function(dir, outputFile, options) {
outputFile = outputFile || path.resolve(dir, "book.pdf");
Q.nfcall(tmp.dir)
diff --git a/bin/utils.js b/bin/utils.js
index f736720..3aa4f18 100644
--- a/bin/utils.js
+++ b/bin/utils.js
@@ -83,7 +83,7 @@ function serveDir(dir, port) {
}
function logError(err) {
- console.log(err.message || err);
+ console.log(err.stack || err.message || err);
return Q.reject(err);
};