certs.js
function mkcert(appDataPath, exe) {
  const logPath = path.join(appDataPath, "mkcert.log")
  const errPath = path.join(appDataPath, "mkcert.err")
  // escape spaces in appDataPath (Mac OS)
  appDataPath = appDataPath.replace(" ", "\\ ")
  const exePath = path.join(appDataPath, exe)
  const crtPath = path.join(appDataPath, "localhost.crt")
  const keyPath = path.join(appDataPath, "localhost.key")
  const cmd = exePath + " -install -cert-file " + crtPath +
    " -key-file " + keyPath + " localhost"
  return new Promise((resolve, reject) => {
    console.log("Running mkcert to generate certificates...")
    exec(cmd, (err, stdout, stderr) => {
      // log
      const errFun = err => {
        /* istanbul ignore if: cannot be tested */
        if (err) console.error(err)
      }
      fs.writeFile(logPath, stdout, errFun)
      fs.writeFile(errPath, stderr, errFun)
      /* istanbul ignore if: cannot be tested */
      if (err) reject(err)
      resolve()
    })
  })
}
function mkcert(appDataPath, exe) {
  const logPath = path.join(appDataPath, "mkcert.log")
  const errPath = path.join(appDataPath, "mkcert.err")
  // escape spaces in appDataPath (Mac OS)
  appDataPath = appDataPath.replace(" ", "\\ ")
  const exePath = path.join(appDataPath, exe)
  const crtPath = path.join(appDataPath, "localhost.crt")
  const keyPath = path.join(appDataPath, "localhost.key")
  const cmd = exePath + " -install -cert-file " + crtPath +
    " -key-file " + keyPath + " localhost"
  return new Promise((resolve, reject) => {
    console.log("Running mkcert to generate certificates...")
    exec(cmd, (err, stdout, stderr) => {
      // log
      const errFun = err => {
        /* istanbul ignore if: cannot be tested */
        if (err) console.error(err)
      }
      fs.writeFile(logPath, stdout, errFun)
      fs.writeFile(errPath, stderr, errFun)
      /* istanbul ignore if: cannot be tested */
      if (err) reject(err)
      resolve()
    })
  })
}
execute the binary executable to generate the certificates