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

Commit8e8fa50

Browse files
committed
working command tracker
1 parentb35f6b1 commit8e8fa50

File tree

5 files changed

+30
-35
lines changed

5 files changed

+30
-35
lines changed

‎src/actions/setupActions.ts

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,10 @@ import * as T from 'typings'
22
import*asGfrom'typings/graphql'
33
import*asvscodefrom'vscode'
44
import*asgitfrom'../services/git'
5-
importnodefrom'../services/node'
65

76
importopenFilesfrom'./utils/openFiles'
87
importloadWatchersfrom'./utils/loadWatchers'
9-
10-
construnCommands=async(commands:string[],send:(action:T.Action)=>void)=>{
11-
if(!commands.length){
12-
return
13-
}
14-
for(constcommandofcommands){
15-
constprocess={
16-
title:command,
17-
description:'Running process',
18-
}
19-
send({type:'COMMAND_START',payload:{process:{ ...process,status:'RUNNING'}}})
20-
const{ stdout, stderr}=awaitnode.exec(command)
21-
if(stderr){
22-
// TODO: distinguish fail & error
23-
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'}}})
27-
}
28-
}
29-
}
8+
importrunCommandsfrom'./utils/runCommands'
309

3110
constsetupActions=async(
3211
workspaceRoot:vscode.WorkspaceFolder,

‎src/actions/utils/runCommands.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import*asTfrom'typings'
2+
importnodefrom'../../services/node'
3+
4+
construnCommands=async(commands:string[],send:(action:T.Action)=>void)=>{
5+
if(!commands.length){
6+
return
7+
}
8+
for(constcommandofcommands){
9+
constprocess={
10+
title:command,
11+
description:'Running process',
12+
}
13+
send({type:'COMMAND_START',payload:{process:{ ...process,status:'RUNNING'}}})
14+
letresult:{stdout:string;stderr:string}
15+
try{
16+
result=awaitnode.exec(command)
17+
}catch(error){
18+
console.log(error)
19+
send({type:'COMMAND_FAIL',payload:{process:{ ...process,status:'FAIL'}}})
20+
return
21+
}
22+
console.log(result.stdout)
23+
send({type:'COMMAND_SUCCESS',payload:{process:{ ...process,status:'SUCCESS'}}})
24+
}
25+
}
26+
27+
exportdefaultrunCommands

‎web-app/src/services/channel/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ class Channel {
5757
case'COMMAND_START':
5858
case'COMMAND_SUCCESS':
5959
case'COMMAND_FAIL':
60-
case'COMMAND_ERROR':
6160
this.machineSend(action)
6261
return
6362
default:

‎web-app/src/services/state/actions/command.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,14 @@ export default {
1717
commandSuccess:assign({
1818
processes:({ processes}:T.MachineContext,event:T.MachineEvent):T.ProcessEvent[]=>{
1919
const{ process}=event.payload
20-
returnprocesses.filter(p=>p.title===process.title)
20+
returnprocesses.filter(p=>p.title!==process.title)
2121
},
2222
}),
2323
//@ts-ignore
2424
commandFail:assign({
2525
processes:({ processes}:T.MachineContext,event:T.MachineEvent):T.ProcessEvent[]=>{
2626
const{ process}=event.payload
27-
returnprocesses.filter(p=>p.title===process.title)
28-
},
29-
}),
30-
//@ts-ignore
31-
commandError:assign({
32-
processes:({ processes}:T.MachineContext,event:T.MachineEvent):T.ProcessEvent[]=>{
33-
const{ process}=event.payload
34-
returnprocesses.filter(p=>p.title===process.title)
27+
returnprocesses.filter(p=>p.title!==process.title)
3528
},
3629
}),
3730
}

‎web-app/src/services/state/machine.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,6 @@ export const machine = Machine<CR.MachineContext, CR.MachineStateSchema, CR.Mach
8888
COMMAND_FAIL:{
8989
actions:['commandFail'],
9090
},
91-
COMMAND_ERROR:{
92-
actions:['commandError'],
93-
},
9491
},
9592
states:{
9693
// TODO: move Initialize into New Tutorial setup

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp