@@ -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+ // #"diff-47d0c00fa3c186f7fc510aad6c9706e5d40404c1952033d7c544d0317de2b80b-18-16-0" data-selected="false" role="gridcell" tabindex="-1" valign="top">
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 [ ] ) => {
2323for ( const command of commands ) {
2424const { stdout, stderr} = await node . exec ( command )
2525if ( stderr ) {
2626console . 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}
3636console . log ( `run command:${ command } ` , stdout )
3737}
@@ -45,7 +45,8 @@ const disposeWatcher = (listener: string) => {
4545delete 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
5051if ( commits ) {
5152for ( const commit of commits ) {
@@ -54,31 +55,50 @@ const setupActions = async (workspaceRoot: vscode.WorkspaceFolder, {commands, co
5455}
5556
5657// 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+ // }
82102
83103// run command
84104if ( commands ) {