Skip to content

Commit 210a49d

Browse files
authored
fix: Cannot read property 'indexOf' of undefined (#200)
* fix: Cannot read property 'indexOf' of undefined * docs: change <path> to [path] * test: update snap
1 parent 3f187f0 commit 210a49d

File tree

9 files changed

+58
-58
lines changed

9 files changed

+58
-58
lines changed

.github/FUNDING.yml

Lines changed: 0 additions & 1 deletion
This file was deleted.

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,12 @@ npm i docsify-cli -g
5050
Use `init` to generate your docs.
5151

5252
```shell
53-
docsify init <path> [--local false] [--theme vue] [--plugins false]
53+
docsify init [path] [--local false] [--theme vue] [--plugins false]
5454

55-
# docsify i <path> [-l false] [-t vue] [--plugins false]
55+
# docsify i [path] [-l false] [-t vue] [--plugins false]
5656
```
5757

58-
`<path>` defaults to the current directory. Use relative paths like `./docs` (or `docs`).
58+
`[path]` defaults to the current directory. Use relative paths like `./docs` (or `docs`).
5959

6060
- `--local` option:
6161
- Shorthand: `-l`
@@ -78,9 +78,9 @@ docsify init <path> [--local false] [--theme vue] [--plugins false]
7878
Run a server on `localhost` with livereload.
7979

8080
```shell
81-
docsify serve <path> [--open false] [--port 3000]
81+
docsify serve [path] [--open false] [--port 3000]
8282

83-
# docsify s <path> [-o false] [-p 3000]
83+
# docsify s [path] [-o false] [-p 3000]
8484
```
8585

8686
- `--open` option:
@@ -99,9 +99,9 @@ docsify serve <path> [--open false] [--port 3000]
9999
Docsify's generators.
100100

101101
```shell
102-
docsify generate <path> [--sidebar _sidebar.md]
102+
docsify generate [path] [--sidebar _sidebar.md]
103103

104-
# docsify g <path> [-s _sidebar.md]
104+
# docsify g [path] [-s _sidebar.md]
105105
```
106106

107107
- `--sidebar` option:

docs/README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ npm i docsify-cli -g
3535
Use `init` to generate your docs.
3636

3737
```shell
38-
docsify init <path> [--local false] [--theme vue] [--plugins false]
38+
docsify init [path] [--local false] [--theme vue] [--plugins false]
3939

40-
# docsify i <path> [-l false] [-t vue] [--plugins false]
40+
# docsify i [path] [-l false] [-t vue] [--plugins false]
4141
```
4242

43-
`<path>` defaults to the current directory. Use relative paths like `./docs` (or `docs`).
43+
`[path]` defaults to the current directory. Use relative paths like `./docs` (or `docs`).
4444

4545
- `--local` option:
4646
- Shorthand: `-l`
@@ -63,9 +63,9 @@ docsify init <path> [--local false] [--theme vue] [--plugins false]
6363
Run a server on `localhost` with livereload.
6464

6565
```shell
66-
docsify serve <path> [--open false] [--port 3000]
66+
docsify serve [path] [--open false] [--port 3000]
6767

68-
# docsify s <path> [-o false] [-p 3000]
68+
# docsify s [path] [-o false] [-p 3000]
6969
```
7070

7171
- `--open` option:
@@ -84,9 +84,9 @@ docsify serve <path> [--open false] [--port 3000]
8484
Docsify's generators.
8585

8686
```shell
87-
docsify generate <path> [--sidebar _sidebar.md]
87+
docsify generate [path] [--sidebar _sidebar.md]
8888

89-
# docsify g <path> [-s _sidebar.md]
89+
# docsify g [path] [-s _sidebar.md]
9090
```
9191

9292
- `--sidebar` option:

e2e/cli.test.js.md

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@ The actual snapshot is saved in `cli.test.js.snap`.
44

55
Generated by [AVA](https://avajs.dev).
66

7-
## rejects promise due to error on passing in an unknown command
7+
## shows up help message without any args
88

99
> Snapshot 1
1010
11-
`Usage: docsify <init|serve> <path>
11+
`Usage: docsify <init|serve> [path]
1212
1313
Commands:␊
1414
docsify init [path] Creates new docs [aliases: i]␊
1515
docsify serve [path] Run local server to preview site. [aliases: s]␊
16-
docsify start <path> Server for SSR␊
17-
docsify generate <path> Docsify's generators [aliases: g]␊
16+
docsify start [path] Server for SSR␊
17+
docsify generate [path] Docsify's generators [aliases: g]␊
1818
1919
Global Options␊
2020
--help, -h Show help [boolean]␊
@@ -27,19 +27,19 @@ Generated by [AVA](https://avajs.dev).
2727
Development:␊
2828
https://github.com/docsifyjs/docsify-cli/blob/master/CONTRIBUTING.md␊
2929
30-
Unknown argument: junkcmd`
30+
[ERROR] 0 arguments passed. Please specify a command`
3131

32-
## shows help with --help flag
32+
## shows help with -h flag
3333

3434
> Snapshot 1
3535
36-
`Usage: docsify <init|serve> <path>
36+
`Usage: docsify <init|serve> [path]
3737
3838
Commands:␊
3939
docsify init [path] Creates new docs [aliases: i]␊
4040
docsify serve [path] Run local server to preview site. [aliases: s]␊
41-
docsify start <path> Server for SSR␊
42-
docsify generate <path> Docsify's generators [aliases: g]␊
41+
docsify start [path] Server for SSR␊
42+
docsify generate [path] Docsify's generators [aliases: g]␊
4343
4444
Global Options␊
4545
--help, -h Show help [boolean]␊
@@ -52,17 +52,17 @@ Generated by [AVA](https://avajs.dev).
5252
Development:␊
5353
https://github.com/docsifyjs/docsify-cli/blob/master/CONTRIBUTING.md`
5454

55-
## shows help with -h flag
55+
## shows help with --help flag
5656

5757
> Snapshot 1
5858
59-
`Usage: docsify <init|serve> <path>
59+
`Usage: docsify <init|serve> [path]
6060
6161
Commands:␊
6262
docsify init [path] Creates new docs [aliases: i]␊
6363
docsify serve [path] Run local server to preview site. [aliases: s]␊
64-
docsify start <path> Server for SSR␊
65-
docsify generate <path> Docsify's generators [aliases: g]␊
64+
docsify start [path] Server for SSR␊
65+
docsify generate [path] Docsify's generators [aliases: g]␊
6666
6767
Global Options␊
6868
--help, -h Show help [boolean]␊
@@ -75,17 +75,35 @@ Generated by [AVA](https://avajs.dev).
7575
Development:␊
7676
https://github.com/docsifyjs/docsify-cli/blob/master/CONTRIBUTING.md`
7777

78-
## shows up help message without any args
78+
## shows version information with -v flag
79+
80+
> Snapshot 1
81+
82+
`␊
83+
docsify-cli version:␊
84+
4.4.4␊
85+
`
86+
87+
## shows version information with --version flag
88+
89+
> Snapshot 1
90+
91+
`␊
92+
docsify-cli version:␊
93+
4.4.4␊
94+
`
95+
96+
## rejects promise due to error on passing in an unknown command
7997

8098
> Snapshot 1
8199
82-
`Usage: docsify <init|serve> <path>
100+
`Usage: docsify <init|serve> [path]
83101
84102
Commands:␊
85103
docsify init [path] Creates new docs [aliases: i]␊
86104
docsify serve [path] Run local server to preview site. [aliases: s]␊
87-
docsify start <path> Server for SSR␊
88-
docsify generate <path> Docsify's generators [aliases: g]␊
105+
docsify start [path] Server for SSR␊
106+
docsify generate [path] Docsify's generators [aliases: g]␊
89107
90108
Global Options␊
91109
--help, -h Show help [boolean]␊
@@ -98,22 +116,4 @@ Generated by [AVA](https://avajs.dev).
98116
Development:␊
99117
https://github.com/docsifyjs/docsify-cli/blob/master/CONTRIBUTING.md␊
100118
101-
[ERROR] 0 arguments passed. Please specify a command`
102-
103-
## shows version information with --version flag
104-
105-
> Snapshot 1
106-
107-
`␊
108-
docsify-cli version:␊
109-
4.4.4␊
110-
`
111-
112-
## shows version information with -v flag
113-
114-
> Snapshot 1
115-
116-
`␊
117-
docsify-cli version:␊
118-
4.4.4␊
119-
`
119+
Unknown argument: junkcmd`

e2e/cli.test.js.snap

3 Bytes
Binary file not shown.

lib/cli.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ require('yargs')
1818
.demandCommand(1, chalk.red('[ERROR] 0 arguments passed. Please specify a command'))
1919
.strict()
2020
.recommendCommands()
21-
.usage(chalk.bold(y18n.__('usage') + ': docsify <init|serve> <path>'))
21+
.usage(chalk.bold(y18n.__('usage') + ': docsify <init|serve> [path]'))
2222
.command({
2323
command: 'init [path]',
2424
aliases: 'i',
@@ -94,7 +94,7 @@ require('yargs')
9494
handler: argv => run.serve(argv.path, argv.open, argv.port, argv.P, argv.i)
9595
})
9696
.command({
97-
command: 'start <path>',
97+
command: 'start [path]',
9898
desc: chalk.gray(y18n.__('start')),
9999
builder: yargs =>
100100
yargs.options({
@@ -118,7 +118,7 @@ require('yargs')
118118
handler: argv => run.start(argv.path, argv.config, argv.port)
119119
})
120120
.command({
121-
command: 'generate <path>',
121+
command: 'generate [path]',
122122
aliases: 'g',
123123
desc: chalk.gray(y18n.__('generate')),
124124
builder: yargs =>

lib/commands/generate.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ const path = require('path')
77
const logger = require('../util/logger')
88
const ignoreFiles = ['_navbar', '_coverpage', '_sidebar']
99

10-
// eslint-disable-next-line
11-
module.exports = function (path = '', sidebar) {
10+
module.exports = function (path, sidebar) {
1211
const cwdPath = cwd(path || '.')
1312

1413
if (exists(cwdPath)) {

tools/locales/en.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,6 @@
1515
"generate.sidebar": "Generate sidebar file",
1616
"livereload.port": "livereload Listen port.",
1717
"usage": "Usage",
18-
"version": "Show version number"
18+
"version": "Show version number",
19+
"gen.sidebar": "Generate sidebar"
1920
}

tools/locales/zh.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,6 @@
1515
"generate.sidebar": "生成侧边栏文件",
1616
"livereload.port": "设置 livereload 端口",
1717
"usage": "例子",
18-
"version": "当前版本号"
18+
"version": "当前版本号",
19+
"gen.sidebar": "生成侧边栏"
1920
}

0 commit comments

Comments
 (0)