diff options
author | Samy Pessé <samypesse@gmail.com> | 2014-05-20 23:07:39 +0200 |
---|---|---|
committer | Samy Pessé <samypesse@gmail.com> | 2014-05-20 23:07:41 +0200 |
commit | 62ec695dc8aa33cbe1062cb9ca98878a664baa28 (patch) | |
tree | 1fea35d522d62b65d6677c5667f597e735afef11 /lib/generate/index.js | |
parent | ca37ac73a9900640d51eeaab825ffc413ac4ec67 (diff) | |
download | gitbook-62ec695dc8aa33cbe1062cb9ca98878a664baa28.zip gitbook-62ec695dc8aa33cbe1062cb9ca98878a664baa28.tar.gz gitbook-62ec695dc8aa33cbe1062cb9ca98878a664baa28.tar.bz2 |
Extract title and description from readme before switching to multi-languages handling
Diffstat (limited to 'lib/generate/index.js')
-rw-r--r-- | lib/generate/index.js | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/lib/generate/index.js b/lib/generate/index.js index b1cbaa6..2a3e441 100644 --- a/lib/generate/index.js +++ b/lib/generate/index.js @@ -84,7 +84,24 @@ var generate = function(options) { } // Check files to get folder type (book, multilanguage book or neither) - return containsFiles(options.input, ['LANGS.md']) + return Q() + + // Read readme + .then(function() { + return fs.readFile(path.join(options.input, "README.md"), "utf-8") + .then(function(_readme) { + _readme = parse.readme(_readme); + + options.title = options.title || _readme.title; + options.description = options.description || _readme.description || defaultDescription; + }); + }) + + // Detect multi-languages book + .then(function() { + return containsFiles(options.input, ['LANGS.md']) + }) + .then(function(isMultiLang) { // Multi language book if(isMultiLang) { @@ -215,17 +232,6 @@ var generateBook = function(options) { // Generate the book return Q() - // Read readme - .then(function() { - return fs.readFile(path.join(options.input, "README.md"), "utf-8") - .then(function(_readme) { - _readme = parse.readme(_readme); - - options.title = options.title || _readme.title; - options.description = options.description || _readme.description || defaultDescription; - }); - }) - // Get summary .then(function() { return fs.readFile(path.join(options.input, "SUMMARY.md"), "utf-8") |