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

Commit72ef62c

Browse files
committed
refactor onValidateSetup
Signed-off-by: shmck <shawn.j.mckay@gmail.com>
1 parent15166d1 commit72ef62c

File tree

3 files changed

+57
-50
lines changed

3 files changed

+57
-50
lines changed

‎src/actions/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
export{defaultasonStartup}from'./onStartup'
22
export{defaultasonTutorialConfig}from'./onTutorialConfig'
33
export{defaultasonTutorialContinueConfig}from'./onTutorialContinueConfig'
4+
export{defaultasonValidateSetup}from'./onValidateSetup'
45
export{defaultasonErrorPage}from'./onErrorPage'
56
export{defaultasonTestPass}from'./onTestPass'

‎src/actions/onValidateSetup.ts

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import*asEfrom'typings/error'
2+
import{version}from'../services/dependencies'
3+
import{checkWorkspaceEmpty}from'../services/workspace'
4+
5+
constonValidateSetup=async(send:any)=>{
6+
try{
7+
// check workspace is selected
8+
constisEmptyWorkspace=awaitcheckWorkspaceEmpty()
9+
if(!isEmptyWorkspace){
10+
consterror:E.ErrorMessage={
11+
type:'WorkspaceNotEmpty',
12+
message:'',
13+
actions:[
14+
{
15+
label:'Open Workspace',
16+
transition:'REQUEST_WORKSPACE',
17+
},
18+
{
19+
label:'Check Again',
20+
transition:'RETRY',
21+
},
22+
],
23+
}
24+
send({type:'VALIDATE_SETUP_FAILED',payload:{ error}})
25+
return
26+
}
27+
// check Git is installed.
28+
// Should wait for workspace before running otherwise requires access to root folder
29+
constisGitInstalled=awaitversion('git')
30+
if(!isGitInstalled){
31+
consterror:E.ErrorMessage={
32+
type:'GitNotFound',
33+
message:'',
34+
actions:[
35+
{
36+
label:'Check Again',
37+
transition:'RETRY',
38+
},
39+
],
40+
}
41+
send({type:'VALIDATE_SETUP_FAILED',payload:{ error}})
42+
return
43+
}
44+
send({type:'SETUP_VALIDATED'})
45+
}catch(e){
46+
consterror={
47+
type:'UknownError',
48+
message:e.message,
49+
}
50+
send({type:'VALIDATE_SETUP_FAILED',payload:{ error}})
51+
}
52+
}
53+
54+
exportdefaultonValidateSetup

‎src/channel.ts

Lines changed: 2 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
import*asTfrom'typings'
22
import*asTTfrom'typings/tutorial'
3-
import*asEfrom'typings/error'
43
import*asvscodefrom'vscode'
54
import{setupActions,solutionActions}from'./actions/setupActions'
65
import{COMMANDS}from'./commands'
76
importContextfrom'./services/context/context'
87
importloggerfrom'./services/logger'
9-
import{version}from'./services/dependencies'
10-
import{openWorkspace,checkWorkspaceEmpty}from'./services/workspace'
8+
import{openWorkspace}from'./services/workspace'
119
import{showOutput}from'./services/testRunner/output'
1210
import{exec}from'./services/node'
1311
importresetfrom'./services/reset'
@@ -48,7 +46,6 @@ class Channel implements Channel {
4846
case'EDITOR_STARTUP':
4947
actions.onStartup(this.context,this.workspaceState,this.send)
5048
return
51-
5249
// clear tutorial local storage
5350
case'TUTORIAL_CLEAR':
5451
// clear current progress/position/tutorial
@@ -62,52 +59,7 @@ class Channel implements Channel {
6259
actions.onTutorialContinueConfig(action,this.context,this.send)
6360
return
6461
case'EDITOR_VALIDATE_SETUP':
65-
try{
66-
// check workspace is selected
67-
constisEmptyWorkspace=awaitcheckWorkspaceEmpty()
68-
if(!isEmptyWorkspace){
69-
consterror:E.ErrorMessage={
70-
type:'WorkspaceNotEmpty',
71-
message:'',
72-
actions:[
73-
{
74-
label:'Open Workspace',
75-
transition:'REQUEST_WORKSPACE',
76-
},
77-
{
78-
label:'Check Again',
79-
transition:'RETRY',
80-
},
81-
],
82-
}
83-
this.send({type:'VALIDATE_SETUP_FAILED',payload:{ error}})
84-
return
85-
}
86-
// check Git is installed.
87-
// Should wait for workspace before running otherwise requires access to root folder
88-
constisGitInstalled=awaitversion('git')
89-
if(!isGitInstalled){
90-
consterror:E.ErrorMessage={
91-
type:'GitNotFound',
92-
message:'',
93-
actions:[
94-
{
95-
label:'Check Again',
96-
transition:'RETRY',
97-
},
98-
],
99-
}
100-
this.send({type:'VALIDATE_SETUP_FAILED',payload:{ error}})
101-
return
102-
}
103-
this.send({type:'SETUP_VALIDATED'})
104-
}catch(e){
105-
consterror={
106-
type:'UknownError',
107-
message:e.message,
108-
}
109-
this.send({type:'VALIDATE_SETUP_FAILED',payload:{ error}})
110-
}
62+
actions.onValidateSetup(this.send)
11163
return
11264
case'EDITOR_REQUEST_WORKSPACE':
11365
openWorkspace()

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp