Skip to content

Commit 1ee437a

Browse files
authored
Merge pull request #22 from perfectacle/fix-bookname-to-title-property
change bookname property to title in book.json
2 parents 0399542 + 0dbf779 commit 1ee437a

File tree

7 files changed

+17
-17
lines changed

7 files changed

+17
-17
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ $ book sm --help
6969
7070
-h, --help output usage information
7171
-r, --root [string] root folder, default is `.`
72-
-n, --bookname [string] book name, default is `Your Book Name`.
72+
-t, --title [string] book title, default is `Your Book Title`.
7373
-c, --catalog [list] catalog folders included book files, default is `all`.
7474
-i, --ignores [list] ignore folders that be excluded, default is `[]`.
7575
-u, --unchanged [list] unchanged catalog like `request.js`, default is `[]`.
@@ -91,7 +91,7 @@ for example:
9191
```
9292
// test/books/config-json/book.json
9393
{
94-
"bookname": "json-config-name",
94+
"title": "json-config-name",
9595
"outputfile": "test.md",
9696
"catalog": "all", // or [chapter1,chapter2, ...]
9797
"ignores": [], //Default: '.*', '_book'...

bin/summary.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ program
2121
.alias("sm")
2222
.description("Generate a `SUMMARY.md` from a folder")
2323
.option("-r, --root [string]", "root folder, default is `.`")
24-
.option("-n, --bookname [string]", "book name, default is `Your Book Name`.")
24+
.option("-t, --title [string]", "book title, default is `Your Book Title`.")
2525
.option("-c, --catalog [list]", "catalog folders included book files, default is `all`.")
2626
.option("-i, --ignores [list]", "ignore folders that be excluded, default is `[]`.", list)
2727
.option("-u, --unchanged [list]", "unchanged catalog like `request.js`, default is `[]`.")

lib/bookJson.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ var path = require('path');
44
function BookConfig(root) {
55

66
var bookJson = path.resolve(root, 'book.json');
7-
var book = config = {};
7+
var book = {}, config = {};
88

99
if (fs.existsSync(bookJson)) {
1010
config = require(bookJson);
@@ -17,7 +17,7 @@ function BookConfig(root) {
1717
book.catalog = config.catalog || 'all';
1818
book.ignores = config.ignores || [];
1919
book.unchanged = config.unchanged || [];
20-
book.bookname = config.bookname || 'Your Book Name';
20+
book.title = config.title || 'Your Book Title';
2121
book.sortedBy = config.sortedBy || '';
2222
book.disableTitleFormatting = config.disableTitleFormatting || false;
2323

lib/summary/index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ var readFile = require('../files');
1515

1616
// Give some variables
1717
var root,
18-
bookname, // todo: don`t use `name`?
18+
title, // todo: don`t use `name`?
1919
outputFile,
2020
catalog,
2121
ignores,
@@ -33,7 +33,7 @@ function init(options) {
3333
catalog = options.catalog || bookConfig.catalog;
3434
ignores = options.ignores || bookConfig.ignores;
3535
unchanged = options.unchanged || bookConfig.unchanged;
36-
bookname = options.bookname || bookConfig.bookname;
36+
title = options.title || bookConfig.title;
3737
sortedBy = options.sortedBy || bookConfig.sortedBy;
3838
disableTitleFormatting = options.disableTitleFormatting || bookConfig.disableTitleFormatting;
3939
}
@@ -71,8 +71,8 @@ function Summary(options) {
7171
}],
7272

7373
write: ['parse', function(next) {
74-
bookname = "# " + bookname + "\n\n";
75-
result += bookname + desc;
74+
title = "# " + title + "\n\n";
75+
result += title + desc;
7676

7777
writeFile(outputFile, result);
7878
}]

test/bookJson.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ var should = require('should');
55
var config = require('../lib/bookJson');
66

77
describe('config.js', function () {
8-
it('should get book.bookname if `book.json` exists', function () {
9-
should(config('test/books/config-json').bookname).be.equal('json-config-name');
8+
it('should get book.title if `book.json` exists', function () {
9+
should(config('test/books/config-json').title).be.equal('json-config-name');
1010
});
1111
});

test/books/config-json/book.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"bookname": "json-config-name",
2+
"title": "json-config-name",
33
"outputfile": "test.md",
44
"catalog": "all",
55
"ignores": [],

test/index.test.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,11 @@ describe('summary/index.js', function() {
4949
});
5050
});
5151

52-
it('given an option bookname, for example: book sm -n bookname', function() {
53-
var bookname = 'This is a test book';
52+
it('given an option title, for example: book sm -t title', function() {
53+
var title = 'This is a test book';
5454
summary({
5555
root: bookRoot,
56-
bookname: bookname
56+
title: title
5757
});
5858

5959
var summaryFile = path.resolve(bookRoot, 'SUMMARY.md');
@@ -67,10 +67,10 @@ describe('summary/index.js', function() {
6767
});
6868

6969
it('given an option ignores, for example: book sm -i test', function() {
70-
var bookname = 'This book has no test';
70+
var title = 'This book has no test';
7171
summary({
7272
root: bookRoot,
73-
bookname: bookname,
73+
title: title,
7474
ignores: ['test']
7575
});
7676

0 commit comments

Comments
 (0)