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

Commite9278c1

Browse files
authored
Merge pull request#50 from ShMcK/feature/file-watcher
Feature/file watcher
2 parents9b7a8d0 +7b0b7c0 commite9278c1

File tree

17 files changed

+362
-279
lines changed

17 files changed

+362
-279
lines changed

‎src/actions/setupActions.ts

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,49 @@ const runCommands = async (commands: string[], language: string = 'JAVASCRIPT')
3737
}
3838
}
3939

40+
// collect active file watchers (listeners)
41+
constwatchers:{[key:string]:vscode.FileSystemWatcher}={}
4042

41-
constsetupActions=async(workspaceRoot:vscode.WorkspaceFolder,{commands, commits, files}:G.StepActions):Promise<void>=>{
43+
constdisposeWatcher=(listener:string)=>{
44+
watchers[listener].dispose()
45+
deletewatchers[listener]
46+
}
47+
48+
constsetupActions=async(workspaceRoot:vscode.WorkspaceFolder,{commands, commits, files, listeners}:G.StepActions):Promise<void>=>{
4249
// run commits
4350
if(commits){
4451
for(constcommitofcommits){
4552
awaitgit.loadCommit(commit)
4653
}
4754
}
4855

56+
// run file watchers (listeners)
57+
if(listeners){
58+
for(constlisteneroflisteners){
59+
if(!watchers[listener]){
60+
constpattern=newvscode.RelativePattern(
61+
vscode.workspace.getWorkspaceFolder(workspaceRoot.uri)!,
62+
listener
63+
)
64+
watchers[listener]=vscode.workspace.createFileSystemWatcher(
65+
pattern
66+
)
67+
watchers[listener].onDidChange(()=>{
68+
// trigger save
69+
vscode.commands.executeCommand('coderoad.run_test',null,()=>{
70+
// cleanup watcher on success
71+
disposeWatcher(listener)
72+
})
73+
})
74+
}
75+
}
76+
}else{
77+
// remove all watchers
78+
for(constlistenerofObject.keys(watchers)){
79+
disposeWatcher(listener)
80+
}
81+
}
82+
4983
// run command
5084
if(commands){
5185
awaitrunCommands(commands)

‎src/editor/commands.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,15 @@ export const createCommands = ({extensionPath, workspaceState, workspaceRoot}: C
5454
// set from last setup stepAction
5555
currentStepId=stepId
5656
},
57-
[COMMANDS.RUN_TEST]:(current:{stepId:string}|undefined)=>{
57+
[COMMANDS.RUN_TEST]:(current:{stepId:string}|undefined,onSuccess:()=>void)=>{
5858
console.log('-------- command.run_test ------ ')
5959
// use stepId from client, or last set stepId
6060
constpayload={stepId:current ?current.stepId :currentStepId}
6161
runTest({
6262
onSuccess:()=>{
6363
// send test pass message back to client
6464
webview.send({type:'TEST_PASS', payload})
65+
onSuccess()
6566
vscode.window.showInformationMessage('PASS')
6667
},
6768
onFail:()=>{

‎typings/graphql.d.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ export type StepActions = {
133133
commits:Array<Scalars['Sha1']>
134134
files?:Maybe<Array<Scalars['String']>>
135135
commands?:Maybe<Array<Scalars['String']>>
136+
listeners?:Maybe<Array<Scalars['String']>>
136137
}
137138

138139
exporttypeTestRunner='JEST'
@@ -494,6 +495,7 @@ export type StepActionsResolvers<
494495
commits?:Resolver<Array<ResolversTypes['Sha1']>,ParentType,ContextType>
495496
files?:Resolver<Maybe<Array<ResolversTypes['String']>>,ParentType,ContextType>
496497
commands?:Resolver<Maybe<Array<ResolversTypes['String']>>,ParentType,ContextType>
498+
listeners?:Resolver<Maybe<Array<ResolversTypes['String']>>,ParentType,ContextType>
497499
}
498500

499501
exporttypeTutorialResolvers<
@@ -632,9 +634,3 @@ export interface IntrospectionResultData {
632634
}[]
633635
}
634636
}
635-
constresult:IntrospectionResultData={
636-
__schema:{
637-
types:[],
638-
},
639-
}
640-
exportdefaultresult

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp