Skip to content

Commit

Permalink
feat: hide process window under Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
hongcha98 committed Oct 26, 2023
1 parent 781b80d commit 4e8d389
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
4 changes: 4 additions & 0 deletions run.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ func (d *PlaywrightDriver) isUpToDateDriver() (bool, error) {
return false, nil
}
cmd := exec.Command(d.DriverBinaryLocation, "--version")
cmd.SysProcAttr = defaultSysProcAttr
output, err := cmd.Output()
if err != nil {
return false, fmt.Errorf("could not run driver: %w", err)
Expand Down Expand Up @@ -193,6 +194,7 @@ func (d *PlaywrightDriver) DownloadDriver() error {

func (d *PlaywrightDriver) run() (*connection, error) {
cmd := exec.Command(d.DriverBinaryLocation, "run-driver")
cmd.SysProcAttr = defaultSysProcAttr
cmd.Stderr = os.Stderr
stdin, err := cmd.StdinPipe()
if err != nil {
Expand Down Expand Up @@ -237,13 +239,15 @@ func (d *PlaywrightDriver) installBrowsers(driverPath string) error {
additionalArgs = append(additionalArgs, d.options.Browsers...)
}
cmd := exec.Command(driverPath, additionalArgs...)
cmd.SysProcAttr = defaultSysProcAttr
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
return cmd.Run()
}

func (d *PlaywrightDriver) uninstallBrowsers(driverPath string) error {
cmd := exec.Command(driverPath, "uninstall")
cmd.SysProcAttr = defaultSysProcAttr
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
return cmd.Run()
Expand Down
7 changes: 7 additions & 0 deletions run_unix.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
//go:build !windows

package playwright

import "syscall"

var defaultSysProcAttr = &syscall.SysProcAttr{}
7 changes: 7 additions & 0 deletions run_win.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
//go:build windows

package playwright

import "syscall"

var defaultSysProcAttr = &syscall.SysProcAttr{HideWindow: true}

0 comments on commit 4e8d389

Please sign in to comment.