@@ -4,34 +4,34 @@ import * as vscode from 'vscode'
4
4
import * as git from '../services/git'
5
5
import node from '../services/node'
6
6
7
- interface ErrorMessageFilter {
8
- [ lang : string ] : {
9
- [ key : string ] : string
10
- }
11
- }
7
+ // interface ErrorMessageFilter {
8
+ // [lang: string]: {
9
+ // [key: string]: string
10
+ // }
11
+ // }
12
12
13
13
// TODO: should be loaded on startup based on language
14
- const commandErrorMessageFilter : ErrorMessageFilter = {
15
- JAVASCRIPT : {
16
- 'node-gyp' : 'Error running npm setup command'
17
- }
18
- }
14
+ // const commandErrorMessageFilter: ErrorMessageFilter = {
15
+ // JAVASCRIPT: {
16
+ // 'node-gyp': 'Error running npm setup command'
17
+ // }
18
+ // }
19
19
20
20
21
21
// TODO: pass command and command name down for filtering. Eg. JAVASCRIPT, 'npm install'
22
- const runCommands = async ( commands : string [ ] , language : string = 'JAVASCRIPT' ) => {
22
+ const runCommands = async ( commands : string [ ] ) => {
23
23
for ( const command of commands ) {
24
24
const { stdout, stderr} = await node . exec ( command )
25
25
if ( stderr ) {
26
26
console . error ( stderr )
27
27
// language specific error messages from running commands
28
- const filteredMessages = Object . keys ( commandErrorMessageFilter [ language ] )
29
- for ( const message of filteredMessages ) {
30
- if ( stderr . match ( message ) ) {
31
- // ignored error
32
- throw new Error ( 'Error running setup command' )
33
- }
34
- }
28
+ // const filteredMessages = Object.keys(commandErrorMessageFilter[language])
29
+ // for (const message of filteredMessages) {
30
+ // if (stderr.match(message)) {
31
+ // // ignored error
32
+ // throw new Error('Error running setup command')
33
+ // }
34
+ // }
35
35
}
36
36
console . log ( `run command: ${ command } ` , stdout )
37
37
}
@@ -45,7 +45,8 @@ const disposeWatcher = (listener: string) => {
45
45
delete watchers [ listener ]
46
46
}
47
47
48
- const setupActions = async ( workspaceRoot : vscode . WorkspaceFolder , { commands, commits, files, listeners} : G . StepActions ) : Promise < void > => {
48
+ const setupActions = async ( workspaceRoot : vscode . WorkspaceFolder , actions : G . StepActions ) : Promise < void > => {
49
+ const { commands, commits, files, listeners} = actions
49
50
// run commits
50
51
if ( commits ) {
51
52
for ( const commit of commits ) {
@@ -54,31 +55,50 @@ const setupActions = async (workspaceRoot: vscode.WorkspaceFolder, {commands, co
54
55
}
55
56
56
57
// run file watchers (listeners)
57
- if ( listeners ) {
58
- for ( const listener of listeners ) {
59
- if ( ! watchers [ listener ] ) {
60
- const pattern = new vscode . 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 ( const listener of Object . keys ( watchers ) ) {
79
- disposeWatcher ( listener )
80
- }
81
- }
58
+ // if (listeners) {
59
+ // console.log('listeners')
60
+ // for (const listener of listeners) {
61
+ // if (!watchers[listener]) {
62
+ // const pattern = new vscode.RelativePattern(
63
+ // vscode.workspace.getWorkspaceFolder(workspaceRoot.uri)!,
64
+ // listener
65
+ // )
66
+ // console.log(pattern)
67
+ // watchers[listener] = vscode.workspace.createFileSystemWatcher(
68
+ // pattern
69
+ // )
70
+ // watchers[listener].onDidChange(() => {
71
+ // console.log('onDidChange')
72
+ // // trigger save
73
+ // vscode.commands.executeCommand('coderoad.run_test', null, () => {
74
+ // // cleanup watcher on success
75
+ // disposeWatcher(listener)
76
+ // })
77
+ // })
78
+ // watchers[listener].onDidCreate(() => {
79
+ // console.log('onDidCreate')
80
+ // // trigger save
81
+ // vscode.commands.executeCommand('coderoad.run_test', null, () => {
82
+ // // cleanup watcher on success
83
+ // disposeWatcher(listener)
84
+ // })
85
+ // })
86
+ // watchers[listener].onDidDelete(() => {
87
+ // console.log('onDidDelete')
88
+ // // trigger save
89
+ // vscode.commands.executeCommand('coderoad.run_test', null, () => {
90
+ // // cleanup watcher on success
91
+ // disposeWatcher(listener)
92
+ // })
93
+ // })
94
+ // }
95
+ // }
96
+ // } else {
97
+ // // remove all watchers
98
+ // for (const listener of Object.keys(watchers)) {
99
+ // disposeWatcher(listener)
100
+ // }
101
+ // }
82
102
83
103
// run command
84
104
if ( commands ) {
0 commit comments