1
- const { createQuestion } = require ( "../utils/createQuestion" ) ;
2
- const { getQuestionToday} = require ( "../utils/getQuestionToday" ) ;
3
- const { fulfillQuestion} = require ( "../utils/fulfillQuestion" ) ;
4
- const { writeStore} = require ( "../utils/store" ) ;
5
- const { getQuestionById} = require ( "../utils/getQuestionById" ) ;
6
- const { getRandomId} = require ( "../utils/getRandomId" ) ;
1
+ import { createQuestion } from "#common/utils/createQuestion.js" ;
2
+ import { getQuestionToday } from "#common/utils/getQuestionToday.js" ;
3
+ import { fulfillQuestion } from "#common/utils/fulfillQuestion.js" ;
4
+ import { writeStore } from "#common/utils/store.js" ;
5
+ import { getQuestionById } from "#common/utils/getQuestionById.js" ;
6
+ import { getRandomId } from "#common/utils/getRandomId.js" ;
7
+
7
8
/**
8
9
* leet-create [-t|-r|-i [id]]
9
10
* 默认参数 -t
@@ -15,10 +16,10 @@ const {getRandomId} = require("../utils/getRandomId");
15
16
const args = process . argv . slice ( 2 ) ;
16
17
switch ( args [ 0 ] ) {
17
18
case "-r" :
18
- getRandomId ( ) . then ( id => {
19
+ getRandomId ( ) . then ( id => {
19
20
getQuestionById ( id ) . then ( question => {
20
21
const random = `${ question . id } .${ question . enName } ` ;
21
- writeStore ( "random-question-info" , question ) ;
22
+ writeStore ( "random-question-info" , question ) ;
22
23
createQuestion ( random ) . then ( ( filePath ) => {
23
24
fulfillQuestion ( filePath , question ) ;
24
25
} )
@@ -27,18 +28,18 @@ switch (args[0]) {
27
28
break ;
28
29
case "-i" :
29
30
const id = args [ 1 ] ;
30
- if ( id === undefined ) {
31
+ if ( id === undefined ) {
31
32
console . warn ( "请指定对应的编号!" )
32
- return ;
33
- }
34
- console . log ( `获取指定编号[ ${ id } ]的题目...` )
35
- getQuestionById ( id ) . then ( question => {
36
- const specified = ` ${ question . id } . ${ question . enName } ` ;
37
- writeStore ( " specified-question-info" , question ) ;
38
- createQuestion ( specified ) . then ( ( filePath ) => {
39
- fulfillQuestion ( filePath , question ) ;
33
+ } else {
34
+ console . log ( `获取指定编号[ ${ id } ]的题目...` )
35
+ getQuestionById ( id ) . then ( question => {
36
+ const specified = ` ${ question . id } . ${ question . enName } ` ;
37
+ writeStore ( "specified- question-info" , question ) ;
38
+ createQuestion ( specified ) . then ( ( filePath ) => {
39
+ fulfillQuestion ( filePath , question ) ;
40
+ } )
40
41
} )
41
- } )
42
+ }
42
43
break ;
43
44
case "-t" :
44
45
default :
0 commit comments