Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 `[]`.
Expand All @@ -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'...
Expand Down
2 changes: 1 addition & 1 deletion bin/summary.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 `[]`.")
Expand Down
4 changes: 2 additions & 2 deletions lib/bookJson.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;

Expand Down
8 changes: 4 additions & 4 deletions lib/summary/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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;
}
Expand Down Expand Up @@ -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);
}]
Expand Down
4 changes: 2 additions & 2 deletions test/bookJson.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});
});
2 changes: 1 addition & 1 deletion test/books/config-json/book.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"bookname": "json-config-name",
"title": "json-config-name",
"outputfile": "test.md",
"catalog": "all",
"ignores": [],
Expand Down
10 changes: 5 additions & 5 deletions test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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']
});

Expand Down