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

Commit803005b

Browse files
committed
restructure order of setup
1 parent75585a6 commit803005b

File tree

1 file changed

+53
-72
lines changed

1 file changed

+53
-72
lines changed

‎src/actions/setupActions.ts

Lines changed: 53 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -4,33 +4,11 @@ import * as vscode from 'vscode'
44
import*asgitfrom'../services/git'
55
importnodefrom'../services/node'
66

7-
// interface ErrorMessageFilter {
8-
// [lang: string]: {
9-
// [key: string]: string
10-
// }
11-
// }
12-
13-
// TODO: should be loaded on startup based on language
14-
// const commandErrorMessageFilter: ErrorMessageFilter = {
15-
// #"diff-47d0c00fa3c186f7fc510aad6c9706e5d40404c1952033d7c544d0317de2b80b-16-6-0" data-selected="false" role="gridcell" tabindex="-1" valign="top">16
-
// 'node-gyp': 'Error running npm setup command'
17-
// }
18-
// }
19-
20-
// TODO: pass command and command name down for filtering. Eg. JAVASCRIPT, 'npm install'
217
construnCommands=async(commands:string[])=>{
228
for(constcommandofcommands){
239
const{ stdout, stderr}=awaitnode.exec(command)
2410
if(stderr){
2511
console.error(stderr)
26-
// language specific error messages from running commands
27-
// const filteredMessages = Object.keys(commandErrorMessageFilter[language])
28-
// for (const message of filteredMessages) {
29-
// if (stderr.match(message)) {
30-
// // ignored error
31-
// throw new Error('Error running setup command')
32-
// }
33-
// }
3412
}
3513
console.log(`run command:${command}`,stdout)
3614
}
@@ -44,64 +22,52 @@ const disposeWatcher = (listener: string) => {
4422
deletewatchers[listener]
4523
}
4624

47-
constsetupActions=async(workspaceRoot:vscode.WorkspaceFolder,actions:G.StepActions):Promise<void>=>{
48-
const{ commands, commits, files, listeners}=actions
49-
// run commits
50-
if(commits){
51-
for(constcommitofcommits){
52-
awaitgit.loadCommit(commit)
53-
}
54-
}
55-
56-
// run file watchers (listeners)
57-
if(listeners){
58-
console.log('listeners')
59-
for(constlisteneroflisteners){
60-
if(!watchers[listener]){
61-
constrootUri=vscode.workspace.getWorkspaceFolder(workspaceRoot.uri)
62-
constpattern=newvscode.RelativePattern(rootUri!,listener)// eslint-disable-line
63-
console.log(pattern)
64-
constlisten=vscode.workspace.createFileSystemWatcher(pattern)
65-
watchers[listener]=listen
66-
watchers[listener].onDidChange(()=>{
67-
console.log('onDidChange')
68-
// trigger save
69-
vscode.commands.executeCommand('coderoad.run_test',null,()=>{
70-
// cleanup watcher on success
71-
disposeWatcher(listener)
72-
})
25+
constloadListeners=(listeners:string[],workspaceUri:vscode.Uri)=>{
26+
for(constlisteneroflisteners){
27+
if(!watchers[listener]){
28+
constrootUri=vscode.workspace.getWorkspaceFolder(workspaceUri)
29+
constpattern=newvscode.RelativePattern(rootUri!,listener)// eslint-disable-line
30+
console.log(pattern)
31+
constlisten=vscode.workspace.createFileSystemWatcher(pattern)
32+
watchers[listener]=listen
33+
watchers[listener].onDidChange(()=>{
34+
console.log('onDidChange')
35+
// trigger save
36+
vscode.commands.executeCommand('coderoad.run_test',null,()=>{
37+
// cleanup watcher on success
38+
disposeWatcher(listener)
7339
})
74-
watchers[listener].onDidCreate(()=>{
75-
console.log('onDidCreate')
76-
// trigger save
77-
vscode.commands.executeCommand('coderoad.run_test',null,()=>{
78-
// cleanup watcher on success
79-
disposeWatcher(listener)
80-
})
40+
})
41+
watchers[listener].onDidCreate(()=>{
42+
console.log('onDidCreate')
43+
// trigger save
44+
vscode.commands.executeCommand('coderoad.run_test',null,()=>{
45+
// cleanup watcher on success
46+
disposeWatcher(listener)
8147
})
82-
watchers[listener].onDidDelete(()=>{
83-
console.log('onDidDelete')
84-
// trigger save
85-
vscode.commands.executeCommand('coderoad.run_test',null,()=>{
86-
// cleanup watcher on success
87-
disposeWatcher(listener)
88-
})
48+
})
49+
watchers[listener].onDidDelete(()=>{
50+
console.log('onDidDelete')
51+
// trigger save
52+
vscode.commands.executeCommand('coderoad.run_test',null,()=>{
53+
// cleanup watcher on success
54+
disposeWatcher(listener)
8955
})
90-
}
91-
}
92-
}else{
93-
// remove all watchers
94-
for(constlistenerofObject.keys(watchers)){
95-
disposeWatcher(listener)
56+
})
9657
}
9758
}
59+
}
9860

99-
// run command
100-
if(commands){
101-
awaitrunCommands(commands)
61+
constsetupActions=async(workspaceRoot:vscode.WorkspaceFolder,actions:G.StepActions):Promise<void>=>{
62+
const{ commands, commits, files, listeners}=actions
63+
// 1. run commits
64+
if(commits){
65+
for(constcommitofcommits){
66+
awaitgit.loadCommit(commit)
67+
}
10268
}
10369

104-
// open files
70+
//2.open files
10571
if(files){
10672
for(constfilePathoffiles){
10773
try{
@@ -131,6 +97,21 @@ const setupActions = async (workspaceRoot: vscode.WorkspaceFolder, actions: G.St
13197
}
13298
}
13399
}
100+
101+
// 3. start file watchers (listeners)
102+
if(listeners){
103+
loadListeners(listeners,workspaceRoot.uri)
104+
}else{
105+
// remove all watchers
106+
for(constlistenerofObject.keys(watchers)){
107+
disposeWatcher(listener)
108+
}
109+
}
110+
111+
// 4. run command
112+
if(commands){
113+
awaitrunCommands(commands)
114+
}
134115
}
135116

136117
exportdefaultsetupActions

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp