EnvFiles returns a list of env files for a project. It has to put the .ddev/.env first It has to put the .ddev/.env.* second Env files ending with .example are ignored.
()
| 1351 | // It has to put the .ddev/.env.* second |
| 1352 | // Env files ending with .example are ignored. |
| 1353 | func (app *DdevApp) EnvFiles() ([]string, error) { |
| 1354 | origDir, _ := os.Getwd() |
| 1355 | defer func() { |
| 1356 | _ = os.Chdir(origDir) |
| 1357 | }() |
| 1358 | err := os.Chdir(app.AppConfDir()) |
| 1359 | if err != nil { |
| 1360 | return nil, err |
| 1361 | } |
| 1362 | envFiles, err := filepath.Glob(".env.*") |
| 1363 | if err != nil { |
| 1364 | return []string{}, fmt.Errorf(".env.* in %s: err=%v", app.AppConfDir(), err) |
| 1365 | } |
| 1366 | |
| 1367 | var orderedEnvFiles []string |
| 1368 | |
| 1369 | webEnvFile := app.GetConfigPath(".env") |
| 1370 | if fileutil.FileExists(webEnvFile) { |
| 1371 | orderedEnvFiles = append(orderedEnvFiles, webEnvFile) |
| 1372 | } |
| 1373 | |
| 1374 | for _, file := range envFiles { |
| 1375 | // Skip .example files |
| 1376 | if strings.HasSuffix(file, ".example") { |
| 1377 | continue |
| 1378 | } |
| 1379 | orderedEnvFiles = append(orderedEnvFiles, app.GetConfigPath(file)) |
| 1380 | } |
| 1381 | |
| 1382 | return orderedEnvFiles, nil |
| 1383 | } |
| 1384 | |
| 1385 | // ProcessHooks executes Tasks defined in Hooks |
| 1386 | func (app *DdevApp) ProcessHooks(hookName string) error { |
no test coverage detected