diff options
author | Aaron O'Mullan <aaron.omullan@friendco.de> | 2014-04-03 16:10:46 -0700 |
---|---|---|
committer | Aaron O'Mullan <aaron.omullan@friendco.de> | 2014-04-03 16:10:47 -0700 |
commit | 1699028688fdcff70a7236ec730be241c9e3f3ec (patch) | |
tree | 3b9d3e101fa35df157b7811902523badfaa74819 /bin/gitbook.js | |
parent | 55d9bfbf1833376d4e79f436eaaf64ed6886ebc8 (diff) | |
download | gitbook-1699028688fdcff70a7236ec730be241c9e3f3ec.zip gitbook-1699028688fdcff70a7236ec730be241c9e3f3ec.tar.gz gitbook-1699028688fdcff70a7236ec730be241c9e3f3ec.tar.bz2 |
Handle empty repoID and print error, fixes #11
Diffstat (limited to 'bin/gitbook.js')
-rwxr-xr-x | bin/gitbook.js | 19 |
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)); |