diff --git a/README.md b/README.md index e764a8f..395d2fc 100644 --- a/README.md +++ b/README.md @@ -69,7 +69,7 @@ $ book sm --help -h, --help output usage information -r, --root [string] root folder, default is `.` - -n, --bookname [string] book name, default is `Your Book Name`. + -t, --title [string] book title, default is `Your Book Title`. -c, --catalog [list] catalog folders included book files, default is `all`. -i, --ignores [list] ignore folders that be excluded, default is `[]`. -u, --unchanged [list] unchanged catalog like `request.js`, default is `[]`. @@ -91,7 +91,7 @@ for example: ``` // test/books/config-json/book.json { - "bookname": "json-config-name", + "title": "json-config-name", "outputfile": "test.md", "catalog": "all", // or [chapter1,chapter2, ...] "ignores": [], //Default: '.*', '_book'... diff --git a/bin/summary.js b/bin/summary.js index 8f3a77d..f8ec4d2 100755 --- a/bin/summary.js +++ b/bin/summary.js @@ -21,7 +21,7 @@ program .alias("sm") .description("Generate a `SUMMARY.md` from a folder") .option("-r, --root [string]", "root folder, default is `.`") - .option("-n, --bookname [string]", "book name, default is `Your Book Name`.") + .option("-t, --title [string]", "book title, default is `Your Book Title`.") .option("-c, --catalog [list]", "catalog folders included book files, default is `all`.") .option("-i, --ignores [list]", "ignore folders that be excluded, default is `[]`.", list) .option("-u, --unchanged [list]", "unchanged catalog like `request.js`, default is `[]`.") diff --git a/lib/bookJson.js b/lib/bookJson.js index 333c244..08ffa66 100644 --- a/lib/bookJson.js +++ b/lib/bookJson.js @@ -4,7 +4,7 @@ var path = require('path'); function BookConfig(root) { var bookJson = path.resolve(root, 'book.json'); - var book = config = {}; + var book = {}, config = {}; if (fs.existsSync(bookJson)) { config = require(bookJson); @@ -17,7 +17,7 @@ function BookConfig(root) { book.catalog = config.catalog || 'all'; book.ignores = config.ignores || []; book.unchanged = config.unchanged || []; - book.bookname = config.bookname || 'Your Book Name'; + book.title = config.title || 'Your Book Title'; book.sortedBy = config.sortedBy || ''; book.disableTitleFormatting = config.disableTitleFormatting || false; diff --git a/lib/summary/index.js b/lib/summary/index.js index 8041114..0950ab7 100644 --- a/lib/summary/index.js +++ b/lib/summary/index.js @@ -15,7 +15,7 @@ var readFile = require('../files'); // Give some variables var root, - bookname, // todo: don`t use `name`? + title, // todo: don`t use `name`? outputFile, catalog, ignores, @@ -33,7 +33,7 @@ function init(options) { catalog = options.catalog || bookConfig.catalog; ignores = options.ignores || bookConfig.ignores; unchanged = options.unchanged || bookConfig.unchanged; - bookname = options.bookname || bookConfig.bookname; + title = options.title || bookConfig.title; sortedBy = options.sortedBy || bookConfig.sortedBy; disableTitleFormatting = options.disableTitleFormatting || bookConfig.disableTitleFormatting; } @@ -71,8 +71,8 @@ function Summary(options) { }], write: ['parse', function(next) { - bookname = "# " + bookname + "\n\n"; - result += bookname + desc; + title = "# " + title + "\n\n"; + result += title + desc; writeFile(outputFile, result); }] diff --git a/test/bookJson.test.js b/test/bookJson.test.js index b73d52c..29bfcce 100644 --- a/test/bookJson.test.js +++ b/test/bookJson.test.js @@ -5,7 +5,7 @@ var should = require('should'); var config = require('../lib/bookJson'); describe('config.js', function () { - it('should get book.bookname if `book.json` exists', function () { - should(config('test/books/config-json').bookname).be.equal('json-config-name'); + it('should get book.title if `book.json` exists', function () { + should(config('test/books/config-json').title).be.equal('json-config-name'); }); }); diff --git a/test/books/config-json/book.json b/test/books/config-json/book.json index aec1ae8..fc5908f 100644 --- a/test/books/config-json/book.json +++ b/test/books/config-json/book.json @@ -1,5 +1,5 @@ { - "bookname": "json-config-name", + "title": "json-config-name", "outputfile": "test.md", "catalog": "all", "ignores": [], diff --git a/test/index.test.js b/test/index.test.js index fd3abe8..f5b093e 100644 --- a/test/index.test.js +++ b/test/index.test.js @@ -49,11 +49,11 @@ describe('summary/index.js', function() { }); }); - it('given an option bookname, for example: book sm -n bookname', function() { - var bookname = 'This is a test book'; + it('given an option title, for example: book sm -t title', function() { + var title = 'This is a test book'; summary({ root: bookRoot, - bookname: bookname + title: title }); var summaryFile = path.resolve(bookRoot, 'SUMMARY.md'); @@ -67,10 +67,10 @@ describe('summary/index.js', function() { }); it('given an option ignores, for example: book sm -i test', function() { - var bookname = 'This book has no test'; + var title = 'This book has no test'; summary({ root: bookRoot, - bookname: bookname, + title: title, ignores: ['test'] });