File tree 6 files changed +31
-12
lines changed
6 files changed +31
-12
lines changed Original file line number Diff line number Diff line change @@ -99,9 +99,9 @@ docsify serve [path] [--open false] [--port 3000]
99
99
Docsify's generators.
100
100
101
101
``` shell
102
- docsify generate [path] [--sidebar _sidebar.md]
102
+ docsify generate [path] [--sidebar _sidebar.md] [--overwrite]
103
103
104
- # docsify g [path] [-s _sidebar.md]
104
+ # docsify g [path] [-s _sidebar.md] [-o]
105
105
```
106
106
107
107
- ` --sidebar ` option:
@@ -110,6 +110,12 @@ docsify generate [path] [--sidebar _sidebar.md]
110
110
- Default: ` _sidebar.md `
111
111
- Description: Generate sidebar file, defaults to ` _sidebar.md ` .
112
112
113
+ - ` --overwrite ` option:
114
+ - Shorthand: ` -o `
115
+ - Type: boolean
116
+ - Default: ` false `
117
+ - Description: Allow overwrite generated files.
118
+
113
119
## Contributing
114
120
Please see the [ Contributing Guidelines] ( ./CONTRIBUTING.md )
115
121
Original file line number Diff line number Diff line change @@ -84,9 +84,9 @@ docsify serve [path] [--open false] [--port 3000]
84
84
Docsify's generators.
85
85
86
86
``` shell
87
- docsify generate [path] [--sidebar _sidebar.md]
87
+ docsify generate [path] [--sidebar _sidebar.md] [--overwrite]
88
88
89
- # docsify g [path] [-s _sidebar.md]
89
+ # docsify g [path] [-s _sidebar.md] [-o]
90
90
```
91
91
92
92
- ` --sidebar ` option:
@@ -95,6 +95,12 @@ docsify generate [path] [--sidebar _sidebar.md]
95
95
- Default: ` _sidebar.md `
96
96
- Description: Generate sidebar file, defaults to ` _sidebar.md ` .
97
97
98
+ - ` --overwrite ` option:
99
+ - Shorthand: ` -o `
100
+ - Type: boolean
101
+ - Default: ` false `
102
+ - Description: Allow overwrite generated files.
103
+
98
104
## License
99
105
100
106
MIT
Original file line number Diff line number Diff line change @@ -123,16 +123,23 @@ require('yargs')
123
123
desc : chalk . gray ( y18n . __ ( 'generate' ) ) ,
124
124
builder : yargs =>
125
125
yargs . options ( {
126
+ overwrite : {
127
+ alias : 'o' ,
128
+ default : false ,
129
+ desc : chalk . gray ( y18n . __ ( 'generate.overwrite' ) ) ,
130
+ nargs : 0 ,
131
+ type : 'boolean'
132
+ } ,
126
133
sidebar : {
127
134
alias : 's' ,
128
135
default : '_sidebar.md' ,
129
- desc : chalk . gray ( y18n . __ ( 'gen .sidebar' ) ) ,
136
+ desc : chalk . gray ( y18n . __ ( 'generate .sidebar' ) ) ,
130
137
nargs : 1 ,
131
138
requiresArg : true ,
132
139
type : 'string'
133
140
}
134
141
} ) ,
135
- handler : argv => run . generate ( argv . path , argv . sidebar )
142
+ handler : argv => run . generate ( argv . path , argv . sidebar , { overwrite : argv . overwrite } )
136
143
} )
137
144
. help ( )
138
145
. option ( 'help' , {
Original file line number Diff line number Diff line change @@ -7,14 +7,14 @@ const path = require('path')
7
7
const logger = require ( '../util/logger' )
8
8
const ignoreFiles = [ '_navbar' , '_coverpage' , '_sidebar' ]
9
9
10
- module . exports = function ( path , sidebar ) {
10
+ module . exports = function ( path , sidebar , options ) {
11
11
const cwdPath = cwd ( path || '.' )
12
12
13
13
if ( exists ( cwdPath ) ) {
14
14
if ( sidebar ) {
15
15
const sidebarPath = cwdPath + '/' + sidebar || '_sidebar.md'
16
16
17
- if ( ! exists ( sidebarPath ) ) {
17
+ if ( ! exists ( sidebarPath ) || options . overwrite ) {
18
18
genSidebar ( cwdPath , sidebarPath )
19
19
logger . success ( `Successfully generated the sidebar file '${ sidebar } '.` )
20
20
return true
Original file line number Diff line number Diff line change 13
13
"serve.indexname" : " Custom filename instead of index.html to serve by default" ,
14
14
"generate" : " Docsify's generators" ,
15
15
"generate.sidebar" : " Generate sidebar file" ,
16
+ "generate.overwrite" : " Allow overwrite generated files" ,
16
17
"livereload.port" : " livereload Listen port." ,
17
18
"usage" : " Usage" ,
18
- "version" : " Show version number" ,
19
- "gen.sidebar" : " Generate sidebar"
19
+ "version" : " Show version number"
20
20
}
Original file line number Diff line number Diff line change 13
13
"serve.indexname" : " 自定义入口文件名,代替默认的 index.html" ,
14
14
"generate" : " docsify 的生成器" ,
15
15
"generate.sidebar" : " 生成侧边栏文件" ,
16
+ "generate.overwrite" : " 允许覆盖生成的文件" ,
16
17
"livereload.port" : " 设置 livereload 端口" ,
17
18
"usage" : " 例子" ,
18
- "version" : " 当前版本号" ,
19
- "gen.sidebar" : " 生成侧边栏"
19
+ "version" : " 当前版本号"
20
20
}
You can’t perform that action at this time.
0 commit comments