@@ -55,11 +55,10 @@ export function humanPath(p?: string): string {
55
55
}
56
56
57
57
export const generateCertificate = async ( ) : Promise < { cert : string ; certKey : string } > => {
58
- const paths = {
59
- cert : path . join ( tmpdir , "self-signed.cert" ) ,
60
- certKey : path . join ( tmpdir , "self-signed.key" ) ,
61
- }
62
- const checks = await Promise . all ( [ fs . pathExists ( paths . cert ) , fs . pathExists ( paths . certKey ) ] )
58
+ const certPath = path . join ( paths . data , "self-signed.cert" )
59
+ const certKeyPath = path . join ( paths . data , "self-signed.key" )
60
+
61
+ const checks = await Promise . all ( [ fs . pathExists ( certPath ) , fs . pathExists ( certKeyPath ) ] )
63
62
if ( ! checks [ 0 ] || ! checks [ 1 ] ) {
64
63
// Require on demand so openssl isn't required if you aren't going to
65
64
// generate certificates.
@@ -69,10 +68,13 @@ export const generateCertificate = async (): Promise<{ cert: string; certKey: st
69
68
return error ? reject ( error ) : resolve ( result )
70
69
} )
71
70
} )
72
- await fs . mkdirp ( tmpdir )
73
- await Promise . all ( [ fs . writeFile ( paths . cert , certs . certificate ) , fs . writeFile ( paths . certKey , certs . serviceKey ) ] )
71
+ await fs . mkdirp ( paths . data )
72
+ await Promise . all ( [ fs . writeFile ( certPath , certs . certificate ) , fs . writeFile ( certKeyPath , certs . serviceKey ) ] )
73
+ }
74
+ return {
75
+ cert : certPath ,
76
+ certKey : certKeyPath ,
74
77
}
75
- return paths
76
78
}
77
79
78
80
export const generatePassword = async ( length = 24 ) : Promise < string > => {
0 commit comments