Skip to content

Commit c273fef

Browse files
committed
two options
1 parent b8565dc commit c273fef

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

envbuilder.go

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1195,7 +1195,7 @@ func (fs *osfsWithChmod) Chmod(name string, mode os.FileMode) error {
11951195
}
11961196

11971197
func findDevcontainerJSON(options Options) (string, string) {
1198-
// 0. Check provided options
1198+
// 0. Check provided options.
11991199
if options.DevcontainerDir != "" || options.DevcontainerJSONPath != "" {
12001200
// Locate .devcontainer directory.
12011201
devcontainerDir := options.DevcontainerDir
@@ -1226,9 +1226,21 @@ func findDevcontainerJSON(options Options) (string, string) {
12261226
return devcontainerDir, devcontainerPath
12271227
}
12281228

1229-
// 1. Check `options.WorkspaceFolder`/.devcontainer/devcontainer.json
1230-
// 2. Check `options.WorkspaceFolder`/devcontainer.json
1231-
// 3. Check every folder: `options.WorkspaceFolder`/<folder>/devcontainer.json
1229+
// 1. Check `options.WorkspaceFolder`/.devcontainer/devcontainer.json.
1230+
location := filepath.Join(options.WorkspaceFolder, ".devcontainer", "devcontainer.json")
1231+
_, err := options.Filesystem.Stat(location)
1232+
if err == nil {
1233+
return filepath.Dir(location), location
1234+
}
1235+
1236+
// 2. Check `options.WorkspaceFolder`/devcontainer.json.
1237+
location = filepath.Join(options.WorkspaceFolder, "devcontainer.json")
1238+
_, err = options.Filesystem.Stat(location)
1239+
if err == nil {
1240+
return filepath.Dir(location), location
1241+
}
1242+
1243+
// 3. Check every folder: `options.WorkspaceFolder`/<folder>/devcontainer.json.
12321244

12331245
panic("not implemented yet")
12341246
}

0 commit comments

Comments
 (0)