@@ -31,17 +31,29 @@ export class ServerlessFunctionModel implements Disposable {
3131 } ) ;
3232 }
3333
34+ /**
35+ * recursivly get the function folders
36+ * @param filePath directory
37+ * @param folders list of function folders
38+ */
39+ getFunctionsFromDir ( filePath : string , folders : Uri [ ] ) {
40+ const fileContents = fs . readdirSync ( filePath , { withFileTypes : true } ) ;
41+ for ( const fileContent of fileContents ) {
42+ if ( fileContent . isDirectory ( ) ) {
43+ if ( fs . existsSync ( path . join ( filePath , fileContent . name , 'func.yaml' ) ) ) {
44+ folders . push ( Uri . file ( path . join ( filePath , fileContent . name ) ) ) ;
45+ }
46+ this . getFunctionsFromDir ( path . join ( filePath , fileContent . name ) , folders ) ;
47+ }
48+ }
49+ }
50+
3451 public async getLocalFunctions ( ) : Promise < FunctionObject [ ] > {
3552 const functionList : FunctionObject [ ] = [ ] ;
3653 const folders : Uri [ ] = [ ] ;
3754 if ( workspace . workspaceFolders ) {
3855 for ( const wf of workspace . workspaceFolders ) {
39- const entries = await fs . readdir ( wf . uri . fsPath , { withFileTypes : true } ) ;
40- for ( const file of entries ) {
41- if ( file . isDirectory ( ) && fs . existsSync ( path . join ( wf . uri . fsPath , file . name , 'func.yaml' ) ) ) {
42- folders . push ( Uri . file ( path . join ( wf . uri . fsPath , file . name ) ) ) ;
43- }
44- }
56+ this . getFunctionsFromDir ( wf . uri . fsPath , folders ) ;
4557 if ( fs . existsSync ( path . join ( wf . uri . fsPath , 'func.yaml' ) ) ) {
4658 folders . push ( wf . uri ) ;
4759 }
0 commit comments