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

Commit9999668

Browse files
committed
setup git actions to send command feedback
1 parent6113648 commit9999668

File tree

3 files changed

+28
-9
lines changed

3 files changed

+28
-9
lines changed

‎src/actions/setupActions.ts

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import*asTfrom'typings'
12
import*asGfrom'typings/graphql'
23
import*asvscodefrom'vscode'
34
import*asgitfrom'../services/git'
@@ -6,25 +7,38 @@ import node from '../services/node'
67
importopenFilesfrom'./utils/openFiles'
78
importloadWatchersfrom'./utils/loadWatchers'
89

9-
construnCommands=async(commands:string[])=>{
10+
construnCommands=async(commands:string[],send:(action:T.Action)=>void)=>{
1011
if(!commands.length){
1112
return
1213
}
1314
for(constcommandofcommands){
15+
constprocess={
16+
title:command,
17+
description:'Running process',
18+
}
19+
send({type:'COMMAND_START',payload:{process:{ ...process,status:'RUNNING'}}})
1420
const{ stdout, stderr}=awaitnode.exec(command)
1521
if(stderr){
22+
// TODO: distinguish fail & error
1623
console.error(stderr)
24+
send({type:'COMMAND_FAIL',payload:{process:{ ...process,status:'FAIL'}}})
25+
}else{
26+
send({type:'COMMAND_SUCCESS',payload:{process:{ ...process,status:'SUCCESS'}}})
1727
}
18-
console.log(`run command:${command}`,stdout)
1928
}
2029
}
2130

22-
constsetupActions=async(workspaceRoot:vscode.WorkspaceFolder,actions:G.StepActions):Promise<void>=>{
31+
constsetupActions=async(
32+
workspaceRoot:vscode.WorkspaceFolder,
33+
actions:G.StepActions,
34+
send:(action:T.Action)=>void,// send messages to client
35+
):Promise<void>=>{
2336
const{ commands, commits, files, watchers}=actions
2437

2538
// 1. run commits
2639
if(commits){
2740
for(constcommitofcommits){
41+
// TODO handle git errors
2842
awaitgit.loadCommit(commit)
2943
}
3044
}
@@ -36,7 +50,7 @@ const setupActions = async (workspaceRoot: vscode.WorkspaceFolder, actions: G.St
3650
loadWatchers(watchers||[],workspaceRoot.uri)
3751

3852
// 4. run command
39-
awaitrunCommands(commands||[])
53+
awaitrunCommands(commands||[],send)
4054
}
4155

4256
exportdefaultsetupActions

‎src/actions/solutionActions.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
1+
import*asTfrom'typings'
12
import*asGfrom'typings/graphql'
23
import*asvscodefrom'vscode'
34
import*asgitfrom'../services/git'
45
importsetupActionsfrom'./setupActions'
56

6-
constsolutionActions=async(workspaceRoot:vscode.WorkspaceFolder,stepActions:G.StepActions):Promise<void>=>{
7+
constsolutionActions=async(
8+
workspaceRoot:vscode.WorkspaceFolder,
9+
stepActions:G.StepActions,
10+
send:(action:T.Action)=>void,
11+
):Promise<void>=>{
712
awaitgit.clear()
8-
returnsetupActions(workspaceRoot,stepActions)
13+
returnsetupActions(workspaceRoot,stepActions,send)
914
}
1015

1116
exportdefaultsolutionActions

‎src/channel/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ class Channel implements Channel {
9393
if(data.init){
9494
constsetup:G.StepActions|null|undefined=data.init.setup
9595
if(setup){
96-
setupActions(this.workspaceRoot,setup)
96+
setupActions(this.workspaceRoot,setup,this.send)
9797
}
9898
}
9999

@@ -119,11 +119,11 @@ class Channel implements Channel {
119119
// load step actions (git commits, commands, open files)
120120
case'SETUP_ACTIONS':
121121
vscode.commands.executeCommand(COMMANDS.SET_CURRENT_STEP,action.payload)
122-
setupActions(this.workspaceRoot,action.payload)
122+
setupActions(this.workspaceRoot,action.payload,this.send)
123123
return
124124
// load solution step actions (git commits, commands, open files)
125125
case'SOLUTION_ACTIONS':
126-
awaitsolutionActions(this.workspaceRoot,action.payload)
126+
awaitsolutionActions(this.workspaceRoot,action.payload,this.send)
127127
// run test following solution to update position
128128
vscode.commands.executeCommand(COMMANDS.RUN_TEST,action.payload)
129129
return

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp