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

Commit31ae47f

Browse files
authored
Merge pull request#418 from coderoad/feature/vscode-commands
Feature/vscode commands
2 parents1ffe8bb +73ba1f7 commit31ae47f

File tree

4 files changed

+34
-1
lines changed

4 files changed

+34
-1
lines changed

‎src/services/hooks/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@ import loadCommits from './utils/loadCommits'
44
importloadWatchersfrom'./utils/loadWatchers'
55
importopenFilesfrom'./utils/openFiles'
66
importrunCommandsfrom'./utils/runCommands'
7+
importrunVSCodeCommandsfrom'./utils/runVSCodeCommands'
78
import{onErrorastelemetryOnError}from'../telemetry'
89
import{onRunTest}from'../../actions/onTest'
910

1011
exportconstonInit=async(actions:TT.StepActions):Promise<void>=>{
1112
awaitloadCommits(actions.commits)
1213
awaitrunCommands(actions.commands)
14+
awaitrunVSCodeCommands(actions.vscodeCommands)
1315
}
1416

1517
exportconstonLevelEnter=async(actions:TT.StepActions):Promise<void>=>{
@@ -23,6 +25,7 @@ export const onSetupEnter = async (actions: TT.StepActions): Promise<void> => {
2325
awaitopenFiles(actions.files)
2426
awaitloadWatchers(actions.watchers)
2527
awaitrunCommands(actions.commands)
28+
awaitrunVSCodeCommands(actions.vscodeCommands)
2629
}
2730

2831
exportconstonSolutionEnter=async(actions:TT.StepActions):Promise<void>=>{
@@ -31,6 +34,7 @@ export const onSolutionEnter = async (actions: TT.StepActions): Promise<void> =>
3134
awaitloadCommits(actions.commits)
3235
awaitopenFiles(actions.files)
3336
awaitrunCommands(actions.commands)
37+
awaitrunVSCodeCommands(actions.vscodeCommands)
3438
awaitonRunTest()
3539
}
3640

‎src/services/hooks/utils/runCommands.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const runCommands = async (commands: string[] = []): Promise<void> => {
1616
result=awaitexec({ command})
1717
console.log(result)
1818
}catch(error){
19-
console.error(`Test failed:${error.message}`)
19+
console.error(`Command failed:${error.message}`)
2020
send({type:'COMMAND_FAIL',payload:{process:{ ...process,status:'FAIL'}}})
2121
return
2222
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import*asvscodefrom'vscode'
2+
import*asTTfrom'typings/tutorial'
3+
4+
// what are VSCode commands?
5+
// - https://code.visualstudio.com/api/references/vscode-api#commands
6+
// a list of commands:
7+
// - https://code.visualstudio.com/api/references/commands (note many take params)
8+
// - https://code.visualstudio.com/docs/getstarted/keybindings (anything keybound is a command)
9+
10+
construnVSCodeCommands=async(commands:TT.VSCodeCommand[]=[]):Promise<void>=>{
11+
if(!commands.length){
12+
return
13+
}
14+
for(constcommandofcommands){
15+
if(typeofcommand==='string'){
16+
// string named commands
17+
awaitvscode.commands.executeCommand(command)
18+
}elseif(Array.isArray(command)){
19+
// array commands with params
20+
const[name,params]=command
21+
awaitvscode.commands.executeCommand(name,params)
22+
}
23+
}
24+
}
25+
26+
exportdefaultrunVSCodeCommands

‎typings/tutorial.d.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ export type StepActions = {
6161
files?:string[]
6262
watchers?:string[]
6363
filter?:string
64+
vscodeCommands?:VSCodeCommand[]
6465
}
6566

6667
exportinterfaceTestRunnerArgs{
@@ -88,3 +89,5 @@ export interface TutorialDependency {
8889
exportinterfaceTutorialAppVersions{
8990
vscode:string
9091
}
92+
93+
exporttypeVSCodeCommand=string|[string,any]

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp