File tree Expand file tree Collapse file tree 2 files changed +11
-6
lines changed Expand file tree Collapse file tree 2 files changed +11
-6
lines changed Original file line number Diff line number Diff line change @@ -32,6 +32,7 @@ export default class Function extends Command {
32
32
name : 'template' ,
33
33
required : false ,
34
34
description : 'Function template' ,
35
+ // TODO: Handle case where no templates are available. Prompt to install template(s).
35
36
choices : getAvailableTemplates ( ) ,
36
37
} ,
37
38
{
Original file line number Diff line number Diff line change @@ -11,12 +11,16 @@ export function isTemplateAvailable(templateName: string): boolean {
11
11
}
12
12
13
13
export function getAvailableTemplates ( ) : string [ ] {
14
- return fs
15
- . readdirSync ( TEMPLATE_DIR , {
16
- withFileTypes : true ,
17
- } )
18
- . filter ( ( dirent ) => dirent . isDirectory ( ) )
19
- . map ( ( dirent ) => dirent . name ) ;
14
+ try {
15
+ return fs
16
+ . readdirSync ( TEMPLATE_DIR , {
17
+ withFileTypes : true ,
18
+ } )
19
+ . filter ( ( dirent ) => dirent . isDirectory ( ) )
20
+ . map ( ( dirent ) => dirent . name ) ;
21
+ } catch ( error ) {
22
+ return [ 'no available templates' ] ;
23
+ }
20
24
}
21
25
22
26
export function createNitricLogDir ( ) : void {
You can’t perform that action at this time.
0 commit comments