@@ -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)
0 commit comments