Skip to content

Commit 6da2891

Browse files
committed
Add devcontainer folder check
1 parent 2db4b86 commit 6da2891

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

cmd/devcontainer/template.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,14 @@ func createTemplateCommand() *cobra.Command {
1919
}
2020

2121
func createTemplateListCommand() *cobra.Command {
22+
isDevcontainerFolder := func(parentPath string, fi os.FileInfo) bool {
23+
if !fi.IsDir() {
24+
return false
25+
}
26+
devcontainerJsonPath := fmt.Sprintf("%s/%s/.devcontainer/devcontainer.json", parentPath, fi.Name())
27+
devContainerJsonInfo, err := os.Stat(devcontainerJsonPath)
28+
return err == nil && !devContainerJsonInfo.IsDir()
29+
}
2230
cmd := &cobra.Command{
2331
Use: "list",
2432
Short: "list templates",
@@ -33,9 +41,8 @@ func createTemplateListCommand() *cobra.Command {
3341
os.Exit(1)
3442
}
3543

36-
fmt.Println("Listing subdir/parent")
3744
for _, entry := range c {
38-
if entry.IsDir() {
45+
if isDevcontainerFolder(folder, entry) {
3946
fmt.Println(entry.Name())
4047
}
4148
}

0 commit comments

Comments
 (0)