Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita9d6561

Browse files
committed
refactor onRunReset
Signed-off-by: shmck <shawn.j.mckay@gmail.com>
1 parent72ef62c commita9d6561

File tree

3 files changed

+34
-26
lines changed

3 files changed

+34
-26
lines changed

‎src/actions/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@ export { default as onStartup } from './onStartup'
22
export{defaultasonTutorialConfig}from'./onTutorialConfig'
33
export{defaultasonTutorialContinueConfig}from'./onTutorialContinueConfig'
44
export{defaultasonValidateSetup}from'./onValidateSetup'
5+
export{defaultasonRunReset}from'./onRunReset'
56
export{defaultasonErrorPage}from'./onErrorPage'
67
export{defaultasonTestPass}from'./onTestPass'

‎src/actions/onRunReset.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import*asTfrom'typings'
2+
import*asTTfrom'typings/tutorial'
3+
importContextfrom'../services/context/context'
4+
import{exec}from'../services/node'
5+
importresetfrom'../services/reset'
6+
importgetLastCommitHashfrom'../services/reset/lastHash'
7+
8+
constonRunReset=async(context:Context)=>{
9+
// reset to timeline
10+
consttutorial:TT.Tutorial|null=context.tutorial.get()
11+
constposition:T.Position=context.position.get()
12+
13+
// get last pass commit
14+
consthash=getLastCommitHash(position,tutorial?.levels||[])
15+
16+
constbranch=tutorial?.config.repo.branch
17+
18+
if(!branch){
19+
console.error('No repo branch found for tutorial')
20+
return
21+
}
22+
23+
// load timeline until last pass commit
24+
reset({ branch, hash})
25+
26+
// if tutorial.config.reset.command, run it
27+
if(tutorial?.config?.reset?.command){
28+
awaitexec({command:tutorial.config.reset.command})
29+
}
30+
}
31+
32+
exportdefaultonRunReset

‎src/channel.ts

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,11 @@
11
import*asTfrom'typings'
2-
import*asTTfrom'typings/tutorial'
32
import*asvscodefrom'vscode'
43
import{setupActions,solutionActions}from'./actions/setupActions'
54
import{COMMANDS}from'./commands'
65
importContextfrom'./services/context/context'
76
importloggerfrom'./services/logger'
87
import{openWorkspace}from'./services/workspace'
98
import{showOutput}from'./services/testRunner/output'
10-
import{exec}from'./services/node'
11-
importresetfrom'./services/reset'
12-
importgetLastCommitHashfrom'./services/reset/lastHash'
13-
149
import*asactionsfrom'./actions'
1510

1611
interfaceChannel{
@@ -88,27 +83,7 @@ class Channel implements Channel {
8883
vscode.commands.executeCommand(COMMANDS.RUN_TEST,action?.payload)
8984
return
9085
case'EDITOR_RUN_RESET':
91-
// reset to timeline
92-
consttutorial:TT.Tutorial|null=this.context.tutorial.get()
93-
constposition:T.Position=this.context.position.get()
94-
95-
// get last pass commit
96-
consthash=getLastCommitHash(position,tutorial?.levels||[])
97-
98-
constbranch=tutorial?.config.repo.branch
99-
100-
if(!branch){
101-
console.error('No repo branch found for tutorial')
102-
return
103-
}
104-
105-
// load timeline until last pass commit
106-
reset({ branch, hash})
107-
108-
// if tutorial.config.reset.command, run it
109-
if(tutorial?.config?.reset?.command){
110-
awaitexec({command:tutorial.config.reset.command})
111-
}
86+
actions.onRunReset(this.context)
11287
return
11388
default:
11489
logger(`No match for action type:${actionType}`)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp