Cleanup path logics with pathExists and binaryExists

This commit is contained in:
Filippo Valsorda
2019-06-01 14:55:58 +01:00
parent b1564cfb0d
commit 245b2732c8
5 changed files with 33 additions and 44 deletions

View File

@@ -245,7 +245,7 @@ func (m *mkcert) makeCertFromCSR() {
// loadCA will load or create the CA at CAROOT.
func (m *mkcert) loadCA() {
if _, err := os.Stat(filepath.Join(m.CAROOT, rootName)); os.IsNotExist(err) {
if !pathExists(filepath.Join(m.CAROOT, rootName)) {
m.newCA()
} else {
log.Printf("Using the local CA at \"%s\" ✨\n", m.CAROOT)
@@ -260,7 +260,7 @@ func (m *mkcert) loadCA() {
m.caCert, err = x509.ParseCertificate(certDERBlock.Bytes)
fatalIfErr(err, "failed to parse the CA certificate")
if _, err := os.Stat(filepath.Join(m.CAROOT, rootKeyName)); os.IsNotExist(err) {
if !pathExists(filepath.Join(m.CAROOT, rootKeyName)) {
return // keyless mode, where only -install works
}