Skip to content

Commit 1574929

Browse files
committed
Remove log files in favour of CLI
1 parent 5dda801 commit 1574929

File tree

1 file changed

+17
-20
lines changed

1 file changed

+17
-20
lines changed

certs.js

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -75,24 +75,21 @@ function download(url, path) {
7575
async function mkcert(appDataPath, exe, domain) {
7676
// fix problems with spaces
7777
/* istanbul ignore next: platform dependent */
78-
const ensureValidPath = function(path) {
79-
// use apex on Windows
80-
if (process.platform === "win32")
81-
return "\"" + path + "\""
78+
const escapeSpaces = function(path) {
8279
// escape spaces (not already escaped)
8380
if (process.platform === "darwin" || process.platform === "linux")
8481
return path.replace(/(?<!\\) /g, "\\ ")
82+
// use apex on Windows
83+
if (process.platform === "win32")
84+
return "\"" + path + "\""
8585
return path
8686
}
8787

88-
const exePath = ensureValidPath(path.join(appDataPath, exe))
89-
const crtPath = ensureValidPath(path.join(appDataPath, domain + ".crt"))
90-
const keyPath = ensureValidPath(path.join(appDataPath, domain + ".key"))
91-
// do not escape: fs.writeFile doesn't want an escaped path
92-
const logPath = path.join(appDataPath, "mkcert.log")
93-
const errPath = path.join(appDataPath, "mkcert.err")
94-
const cmd = exePath + " -install -cert-file " + crtPath +
95-
" -key-file " + keyPath + " " + domain
88+
const exePath = escapeSpaces(path.join(appDataPath, exe))
89+
const crtPath = escapeSpaces(path.join(appDataPath, domain + ".crt"))
90+
const keyPath = escapeSpaces(path.join(appDataPath, domain + ".key"))
91+
const cmd = `${exePath} -install -cert-file ${crtPath}` +
92+
` -key-file ${keyPath} ${domain}`
9693

9794
// sleep on windows due to issue #28
9895
/* istanbul ignore if: cannot be tested */
@@ -103,15 +100,15 @@ async function mkcert(appDataPath, exe, domain) {
103100
console.log("Running mkcert to generate certificates...")
104101
// run the mkcert command
105102
exec(cmd, (err, stdout, stderr) => {
106-
// log
107-
const errFun = err => {
108-
/* istanbul ignore if: cannot be tested */
109-
if (err) console.error(err)
110-
}
111-
fs.writeFile(logPath, stdout, errFun)
112-
fs.writeFile(errPath, stderr, errFun)
113103
/* istanbul ignore if: cannot be tested */
114-
if (err) reject(err)
104+
if (stdout) console.log(stdout)
105+
/* istanbul ignore next: cannot be tested */
106+
if (stderr) console.error(stderr)
107+
/* istanbul ignore if: cannot be tested */
108+
if (err) {
109+
console.error(err)
110+
reject(err)
111+
}
115112
resolve()
116113
})
117114
})

0 commit comments

Comments
 (0)