Skip to content

Commit 5dda801

Browse files
committed
Sleep 3 seconds on Windows (issue #28)
1 parent d5a8ad6 commit 5dda801

File tree

3 files changed

+57
-51
lines changed

3 files changed

+57
-51
lines changed

certs.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ function getExe() {
4646
if (process.arch === "arm" || process.arch === "arm64")
4747
return "mkcert-" + MKCERT_VERSION + "-linux-arm"
4848
else return "mkcert-" + MKCERT_VERSION + "-linux-amd64"
49-
/* falls through */
49+
/* falls through */
5050
case "win32":
5151
return "mkcert-" + MKCERT_VERSION + "-windows-amd64.exe"
5252
default:
@@ -72,7 +72,7 @@ function download(url, path) {
7272
}
7373

7474
// execute the binary executable to generate the certificates
75-
function mkcert(appDataPath, exe, domain) {
75+
async function mkcert(appDataPath, exe, domain) {
7676
// fix problems with spaces
7777
/* istanbul ignore next: platform dependent */
7878
const ensureValidPath = function(path) {
@@ -91,11 +91,17 @@ function mkcert(appDataPath, exe, domain) {
9191
// do not escape: fs.writeFile doesn't want an escaped path
9292
const logPath = path.join(appDataPath, "mkcert.log")
9393
const errPath = path.join(appDataPath, "mkcert.err")
94-
9594
const cmd = exePath + " -install -cert-file " + crtPath +
9695
" -key-file " + keyPath + " " + domain
96+
97+
// sleep on windows due to issue #28
98+
/* istanbul ignore if: cannot be tested */
99+
if (process.platform === "win32")
100+
await new Promise(resolve => setTimeout(resolve, 3000))
101+
97102
return new Promise((resolve, reject) => {
98103
console.log("Running mkcert to generate certificates...")
104+
// run the mkcert command
99105
exec(cmd, (err, stdout, stderr) => {
100106
// log
101107
const errFun = err => {
@@ -142,7 +148,7 @@ async function getCerts(customDomain = undefined) {
142148
if (process.pkg) checkUpdates()
143149
// check if a reinstall is forced or needed by a mkcert update
144150
if (process.env.REINSTALL ||
145-
!fs.existsSync(path.join(certPath, getExe())))
151+
!fs.existsSync(path.join(certPath, getExe())))
146152
await generate(certPath, domain)
147153
try {
148154
return {
@@ -153,7 +159,7 @@ async function getCerts(customDomain = undefined) {
153159
/* istanbul ignore else: should never occur */
154160
if (certPath !== CERT_PATH) {
155161
console.error("Cannot find localhost.key and localhost.crt in the" +
156-
" specified path: " + certPath)
162+
" specified path: " + certPath)
157163
process.exit(1)
158164
} else {
159165
// Missing certificates (first run)

package-lock.json

Lines changed: 43 additions & 43 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,14 @@
5050
"spdy": "^4.0.2"
5151
},
5252
"devDependencies": {
53-
"eslint": "^7.8.1",
53+
"eslint": "^7.10.0",
5454
"eslint-config-standard": "^14.1.1",
55-
"eslint-plugin-import": "^2.22.0",
55+
"eslint-plugin-import": "^2.22.1",
5656
"eslint-plugin-node": "^11.1.0",
5757
"eslint-plugin-promise": "^4.2.1",
5858
"eslint-plugin-standard": "^4.0.1",
5959
"mocha": "^8.1.3",
6060
"nyc": "^15.1.0",
61-
"sinon": "^9.0.3"
61+
"sinon": "^9.2.0"
6262
}
6363
}

0 commit comments

Comments
 (0)