Explorar o código

Avoid printing a success message on error

Updates #51
Filippo Valsorda %!s(int64=6) %!d(string=hai) anos
pai
achega
ba12bc5899
Modificáronse 2 ficheiros con 6 adicións e 10 borrados
  1. 2 3
      main.go
  2. 4 7
      truststore_nss.go

+ 2 - 3
main.go

@@ -174,10 +174,9 @@ func (m *mkcert) install() {
 		printed = true
 	}
 	if hasNSS && !m.checkNSS() {
-		if hasCertutil {
-			m.installNSS()
+		if hasCertutil && m.installNSS() {
 			log.Printf("The local CA is now installed in the %s trust store (requires browser restart)! 🦊", NSSBrowsers)
-		} else {
+		} else if !hasCertutil {
 			log.Printf(`Warning: "certutil" is not available, so the CA can't be automatically installed in %s! ⚠️`, NSSBrowsers)
 			log.Printf(`Install "certutil" with "%s" and re-run "mkcert -install" 👈`, CertutilInstallHelp)
 		}

+ 4 - 7
truststore_nss.go

@@ -56,24 +56,21 @@ func (m *mkcert) checkNSS() bool {
 	return success
 }
 
-func (m *mkcert) installNSS() {
+func (m *mkcert) installNSS() bool {
 	if m.forEachNSSProfile(func(profile string) {
 		cmd := exec.Command(certutilPath, "-A", "-d", profile, "-t", "C,,", "-n", m.caUniqueName(), "-i", filepath.Join(m.CAROOT, rootName))
 		out, err := cmd.CombinedOutput()
-		if err != nil {
-			log.Printf("!!! You've hit a known issue. Please report the entire command output at https://github.com/FiloSottile/mkcert/issues/12\nProfile path: %s\nOS: %s/%s\ncertutil: %s\n", profile, runtime.GOOS, runtime.GOARCH, certutilPath)
-			cmd := exec.Command("ls", "-l", profile[4:])
-			cmd.Stdout, cmd.Stderr = os.Stderr, os.Stderr
-			cmd.Run()
-		}
 		fatalIfCmdErr(err, "certutil -A", out)
 	}) == 0 {
 		log.Printf("ERROR: no %s security databases found", NSSBrowsers)
+		return false
 	}
 	if !m.checkNSS() {
 		log.Printf("Installing in %s failed. Please report the issue with details about your environment at https://github.com/FiloSottile/mkcert/issues/new 👎", NSSBrowsers)
 		log.Printf("Note that if you never started %s, you need to do that at least once.", NSSBrowsers)
+		return false
 	}
+	return true
 }
 
 func (m *mkcert) uninstallNSS() {