@@ -4,34 +4,34 @@ import * as vscode from 'vscode'
44import * as git from '../services/git'
55import node from '../services/node'
66
7- interface ErrorMessageFilter {
8- [ lang : string ] : {
9- [ key : string ] : string
10- }
11- }
7+ // interface ErrorMessageFilter {
8+ // [lang: string]: {
9+ // [key: string]: string
10+ // }
11+ // }
1212
1313// 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+ // }
1919
2020
2121// 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 [ ] ) => {
2323 for ( const command of commands ) {
2424 const { stdout, stderr} = await node . exec ( command )
2525 if ( stderr ) {
2626 console . error ( stderr )
2727 // 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+ // }
3535 }
3636 console . log ( `run command: ${ command } ` , stdout )
3737 }
@@ -45,7 +45,8 @@ const disposeWatcher = (listener: string) => {
4545 delete watchers [ listener ]
4646}
4747
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
4950 // run commits
5051 if ( commits ) {
5152 for ( const commit of commits ) {
@@ -55,16 +56,36 @@ const setupActions = async (workspaceRoot: vscode.WorkspaceFolder, {commands, co
5556
5657 // run file watchers (listeners)
5758 if ( listeners ) {
59+ console . log ( 'listeners' )
5860 for ( const listener of listeners ) {
5961 if ( ! watchers [ listener ] ) {
6062 const pattern = new vscode . RelativePattern (
6163 vscode . workspace . getWorkspaceFolder ( workspaceRoot . uri ) ! ,
6264 listener
6365 )
64- watchers [ listener ] = vscode . workspace . createFileSystemWatcher (
66+ console . log ( pattern )
67+ const listen = vscode . workspace . createFileSystemWatcher (
6568 pattern
6669 )
70+ watchers [ listener ] = listen
6771 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' )
6889 // trigger save
6990 vscode . commands . executeCommand ( 'coderoad.run_test' , null , ( ) => {
7091 // cleanup watcher on success
0 commit comments