Merge 68ecc23126
into 5c76d3e02c
This commit is contained in:
commit
f2331b072b
|
@ -0,0 +1 @@
|
|||
FOO=BAR
|
|
@ -137,7 +137,10 @@ func Unmarshal(str string) (envMap map[string]string, err error) {
|
|||
// If you want more fine grained control over your command it's recommended
|
||||
// that you use `Load()` or `Read()` and the `os/exec` package yourself.
|
||||
func Exec(filenames []string, cmd string, cmdArgs []string) error {
|
||||
Load(filenames...)
|
||||
err := Load(filenames...)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
command := exec.Command(cmd, cmdArgs...)
|
||||
command.Stdin = os.Stdin
|
||||
|
|
|
@ -2,10 +2,12 @@ package godotenv
|
|||
|
||||
import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"reflect"
|
||||
"strings"
|
||||
"syscall"
|
||||
"testing"
|
||||
)
|
||||
|
||||
|
@ -472,3 +474,11 @@ func TestRoundtrip(t *testing.T) {
|
|||
|
||||
}
|
||||
}
|
||||
|
||||
func TestExecWhenFileNotFound(t *testing.T) {
|
||||
fileNames := []string{"not-existed-file-name.env"}
|
||||
err := Exec(fileNames, "", []string{})
|
||||
if !errors.Is(err, syscall.ERROR_FILE_NOT_FOUND) {
|
||||
t.Error("Expected: return error when system cannot find the file specified")
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue