Skip to content

Commit

Permalink
fix(functions/serve): error out when env file not found
Browse files Browse the repository at this point in the history
  • Loading branch information
soedirgo committed Mar 31, 2022
1 parent 7faf30d commit 72509c1
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions internal/functions/serve/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ func Run(envFilePath string, slug string) error {
if err := utils.ValidateFunctionSlug(slug); err != nil {
return err
}
if envFilePath != "" {
if _, err := os.ReadFile(envFilePath); err != nil {
return fmt.Errorf("Failed to read env file: %w", err)
}
}
}

// 2. Stop on SIGINT/SIGTERM.
Expand Down Expand Up @@ -116,9 +121,7 @@ func Run(envFilePath string, slug string) error {
// skip
} else {
envMap, err := godotenv.Read(envFilePath)
if errors.Is(err, os.ErrNotExist) {
// skip
} else if err != nil {
if err != nil {
return err
}
for name, value := range envMap {
Expand Down

0 comments on commit 72509c1

Please sign in to comment.