@@ -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 ) {
@@ -55,16 +56,36 @@ const setupActions = async (workspaceRoot: vscode.WorkspaceFolder, {commands, co
55
56
56
57
// run file watchers (listeners)
57
58
if ( listeners ) {
59
+ console . log ( 'listeners' )
58
60
for ( const listener of listeners ) {
59
61
if ( ! watchers [ listener ] ) {
60
62
const pattern = new vscode . RelativePattern (
61
63
vscode . workspace . getWorkspaceFolder ( workspaceRoot . uri ) ! ,
62
64
listener
63
65
)
64
- watchers [ listener ] = vscode . workspace . createFileSystemWatcher (
66
+ console . log ( pattern )
67
+ const listen = vscode . workspace . createFileSystemWatcher (
65
68
pattern
66
69
)
70
+ watchers [ listener ] = listen
67
71
watchers [ listener ] . onDidChange ( ( ) => {
72
+ console . log ( 'onDidChange' )
73
+ // trigger save
74
+ vscode . commands . executeCommand ( 'coderoad.run_test' , null , ( ) => {
75
+ // cleanup watcher on success
76
+ disposeWatcher ( listener )
77
+ } )
78
+ } )
79
+ watchers [ listener ] . onDidCreate ( ( ) => {
80
+ console . log ( 'onDidCreate' )
81
+ // trigger save
82
+ vscode . commands . executeCommand ( 'coderoad.run_test' , null , ( ) => {
83
+ // cleanup watcher on success
84
+ disposeWatcher ( listener )
85
+ } )
86
+ } )
87
+ watchers [ listener ] . onDidDelete ( ( ) => {
88
+ console . log ( 'onDidDelete' )
68
89
// trigger save
69
90
vscode . commands . executeCommand ( 'coderoad.run_test' , null , ( ) => {
70
91
// cleanup watcher on success
0 commit comments