(cmd ...string)
| 380 | var sudoWarningOnce sync.Once |
| 381 | |
| 382 | func commandWithSudo(cmd ...string) *exec.Cmd { |
| 383 | if u, err := user.Current(); err == nil && u.Uid == "0" { |
| 384 | return exec.Command(cmd[0], cmd[1:]...) |
| 385 | } |
| 386 | if !binaryExists("sudo") { |
| 387 | sudoWarningOnce.Do(func() { |
| 388 | log.Println(`Warning: "sudo" is not available, and mkcert is not running as root. The (un)install operation might fail. ⚠️`) |
| 389 | }) |
| 390 | return exec.Command(cmd[0], cmd[1:]...) |
| 391 | } |
| 392 | return exec.Command("sudo", append([]string{"--prompt=Sudo password:", "--"}, cmd...)...) |
| 393 | } |
no test coverage detected
searching dependent graphs…