From 614b9483893d8b9a2f528ad283041f6c038fa99b Mon Sep 17 00:00:00 2001 From: Can Stand <70889873+canstand@users.noreply.github.com> Date: Fri, 13 Sep 2024 23:08:14 +0800 Subject: [PATCH] feat: add PLAYWRIGHT_DRIVER_PATH env to specify the driver directory --- run.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/run.go b/run.go index 18d543f7..f727c44c 100644 --- a/run.go +++ b/run.go @@ -37,6 +37,9 @@ type PlaywrightDriver struct { func NewDriver(options *RunOptions) (*PlaywrightDriver, error) { baseDriverDirectory := options.DriverDirectory + if baseDriverDirectory == "" { + baseDriverDirectory := os.Getenv("PLAYWRIGHT_DRIVER_PATH") + } if baseDriverDirectory == "" { var err error baseDriverDirectory, err = getDefaultCacheDirectory() @@ -52,10 +55,6 @@ func NewDriver(options *RunOptions) (*PlaywrightDriver, error) { } func getDefaultCacheDirectory() (string, error) { - if cachePath := os.Getenv("PLAYWRIGHT_BROWSERS_PATH"); cachePath != "" { - return cachePath, nil - } - userHomeDir, err := os.UserHomeDir() if err != nil { return "", fmt.Errorf("could not get user home directory: %w", err)