summaryrefslogtreecommitdiffstats
path: root/bin/gitbook.js
diff options
context:
space:
mode:
Diffstat (limited to 'bin/gitbook.js')
-rwxr-xr-xbin/gitbook.js19
1 files changed, 14 insertions, 5 deletions
diff --git a/bin/gitbook.js b/bin/gitbook.js
index c21b955..0017cb1 100755
--- a/bin/gitbook.js
+++ b/bin/gitbook.js
@@ -31,32 +31,41 @@ prog
.action(buildFunc = function(dir, options) {
dir = dir || process.cwd();
outputDir = options.output || path.join(dir, '_book');
-
+
console.log('Starting build ...');
// Get repo's URL
return utils.gitURL(dir)
.then(function(url) {
// Get ID of repo
return utils.githubID(url);
+ }, function(err) {
+ return null;
})
.then(function(repoID) {
- var parts = repoID.split('/', 2);
+ var githubID = options.github || repoID;
+
+ if(!githubID) {
+ throw new Error('Needs a githubID (username/repo). Either set repo origin to a github repo or use the -g flag');
+ }
+
+ var parts = githubID.split('/', 2);
var user = parts[0], repo = parts[1];
+ var title = options.title || utils.titleCase(repo);
+
return generate.folder(
dir,
outputDir,
{
- title: options.title || utils.titleCase(repo),
+ title: title,
description: options.intro,
- github: options.github || repoID
+ github: githubID
}
);
})
.then(function(output) {
console.log("Successfuly built !");
}, function(err) {
- console.log(err.stack || err);
throw err;
})
.then(_.constant(outputDir));