@@ -31,15 +31,15 @@ program
31
31
. option ( '-t, --today' , 'Check the question today.' )
32
32
. option (
33
33
'-i, --identity <identity>' ,
34
- 'Check the specified question by identity.'
34
+ 'Check the specified question by identity.' ,
35
35
)
36
36
. option ( '-r, --random' , 'Check the last random question.' )
37
37
. option ( '-e, --easy' , 'Use easy mode.' )
38
38
. option ( '-d, --directory <directory>' , 'Set the question directory.' )
39
39
. option ( '-l, --language [language]' , 'Set/Get the code language of question.' )
40
40
. option (
41
41
'-u, --update' ,
42
- 'Check the version to determine whether to update to the latest one.'
42
+ 'Check the version to determine whether to update to the latest one.' ,
43
43
)
44
44
. parse ( process . argv )
45
45
@@ -59,13 +59,14 @@ async function check(mode, question) {
59
59
const filePath = path . join (
60
60
baseDir ,
61
61
getQuestionFileName ( question ) ,
62
- `question${ getQuestionFileExtension ( question ?. lang ) } `
62
+ `question${ getQuestionFileExtension ( question ?. lang ) } ` ,
63
63
)
64
64
if ( ! fs . existsSync ( filePath ) ) {
65
65
logger . info ( `文件[${ filePath } ]不存在,请确保已经创建!` )
66
- } else {
66
+ }
67
+ else {
67
68
logger . info (
68
- `MODE: ${ mode } \n题目[${ getQuestionChineseName ( question ) } ]检查结果:`
69
+ `MODE: ${ mode } \n题目[${ getQuestionChineseName ( question ) } ]检查结果:` ,
69
70
)
70
71
await checkQuestionByPath ( filePath )
71
72
}
@@ -89,13 +90,14 @@ const callModeAction = {
89
90
// 如果未指定id说明是要检测模式创建的题目
90
91
question = await getQuestionByMode ( mode )
91
92
await check ( 'identity' , question )
92
- } else {
93
+ }
94
+ else {
93
95
question = await getFilePathById ( id )
94
96
const needToSelect = {
95
97
type : 'list' ,
96
98
name : 'need' ,
97
99
message : `在当前目录下存在id为[${ id } ]的题目副本,请选择你要检查的副本:` ,
98
- choices : [ ]
100
+ choices : [ ] ,
99
101
}
100
102
/**
101
103
* 只检查一个题目
@@ -108,13 +110,13 @@ const callModeAction = {
108
110
name : 'check' ,
109
111
message : '当前题目目录中存在多个题目文件副本,请选择一个进行检查:' ,
110
112
choices : [ ] ,
111
- default : null
113
+ default : null ,
112
114
}
113
115
let filePath
114
116
switch ( typeof fileOrFiles ) {
115
117
case 'undefined' :
116
118
logger . warn (
117
- `虽然在题目目录中,但当前目录下不存在[${ id } ]的题目文件!`
119
+ `虽然在题目目录中,但当前目录下不存在[${ id } ]的题目文件!` ,
118
120
)
119
121
process . exit ( 0 )
120
122
break
@@ -125,8 +127,8 @@ const callModeAction = {
125
127
needToCheck . choices = fileOrFiles . map ( ( o ) => {
126
128
return { name : o , value : o }
127
129
} )
128
- needToCheck . default = fileOrFiles ?. find ( ( o ) =>
129
- o . endsWith ( getQuestionFileExtension ( DefaultLang ) )
130
+ needToCheck . default = fileOrFiles ?. find ( o =>
131
+ o . endsWith ( getQuestionFileExtension ( DefaultLang ) ) ,
130
132
)
131
133
filePath = await select ( needToCheck )
132
134
break
@@ -155,7 +157,7 @@ const callModeAction = {
155
157
await checkOne ( files )
156
158
}
157
159
process . exit ( 0 )
158
- }
160
+ } ,
159
161
}
160
162
// 执行指令分发
161
163
callModeAction [ mode ] ( args )
0 commit comments