From e57a331e5c3c3b51ba749c196f092966b9ae233e Mon Sep 17 00:00:00 2001 From: ljun20160606 Date: Wed, 23 May 2018 15:53:19 +0800 Subject: [PATCH] fix: windows tempfile path in %USERPROFILE%\AppData\Local #13 --- runner/runner.go | 2 +- runner/runner_unix.go | 4 ++-- runner/runner_windows.go | 6 ++++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/runner/runner.go b/runner/runner.go index 4466586..b21afbe 100644 --- a/runner/runner.go +++ b/runner/runner.go @@ -140,7 +140,7 @@ func (r *Runner) Start(ctxt context.Context) error { _, ok = r.opts["user-data-dir"] if !ok { r.opts["user-data-dir"], err = ioutil.TempDir( - DefaultUserDataTmpDir, fmt.Sprintf(DefaultUserDataDirPrefix, r.Port()), + defaultUserDataTmpDir, fmt.Sprintf(DefaultUserDataDirPrefix, r.Port()), ) if err != nil { return err diff --git a/runner/runner_unix.go b/runner/runner_unix.go index 860e9f0..3f0c1d8 100644 --- a/runner/runner_unix.go +++ b/runner/runner_unix.go @@ -7,10 +7,10 @@ import ( "syscall" ) -const ( +var ( // DefaultUserDataTmpDir is the default directory path for created user // data directories. - DefaultUserDataTmpDir = "/tmp" + defaultUserDataTmpDir = "/tmp" ) // KillProcessGroup is a Chrome command line option that will instruct the diff --git a/runner/runner_windows.go b/runner/runner_windows.go index fe61fca..4d274e6 100644 --- a/runner/runner_windows.go +++ b/runner/runner_windows.go @@ -2,8 +2,10 @@ package runner -const ( - DefaultUserDataTmpDir = `c:\temp` +import "os" + +var ( + defaultUserDataTmpDir = os.Getenv("USERPROFILE") + `\AppData\Local` ) // KillProcessGroup is a Chrome command line option that will instruct the