@@ -545,11 +545,18 @@ class Server {
545
545
if ( ! options . https . key || ! options . https . cert ) {
546
546
const certificateDir = Server . findCacheDir ( ) ;
547
547
const certificatePath = path . join ( certificateDir , "server.pem" ) ;
548
- let certificateExists = fs . existsSync ( certificatePath ) ;
548
+ let certificateExists ;
549
+
550
+ try {
551
+ const certificate = await fs . promises . stat ( certificatePath ) ;
552
+ certificateExists = certificate . isFile ( ) ;
553
+ } catch {
554
+ certificateExists = false ;
555
+ }
549
556
550
557
if ( certificateExists ) {
551
558
const certificateTtl = 1000 * 60 * 60 * 24 ;
552
- const certificateStat = fs . statSync ( certificatePath ) ;
559
+ const certificateStat = await fs . promises . stat ( certificatePath ) ;
553
560
554
561
const now = new Date ( ) ;
555
562
@@ -561,7 +568,7 @@ class Server {
561
568
"SSL Certificate is more than 30 days old. Removing..."
562
569
) ;
563
570
564
- del . sync ( [ certificatePath ] , { force : true } ) ;
571
+ await del ( [ certificatePath ] , { force : true } ) ;
565
572
566
573
certificateExists = false ;
567
574
}
@@ -634,13 +641,18 @@ class Server {
634
641
] ,
635
642
} ) ;
636
643
637
- fs . mkdirSync ( certificateDir , { recursive : true } ) ;
638
- fs . writeFileSync ( certificatePath , pems . private + pems . cert , {
639
- encoding : "utf8" ,
640
- } ) ;
644
+ await fs . promises . mkdir ( certificateDir , { recursive : true } ) ;
645
+
646
+ await fs . promises . writeFile (
647
+ certificatePath ,
648
+ pems . private + pems . cert ,
649
+ {
650
+ encoding : "utf8" ,
651
+ }
652
+ ) ;
641
653
}
642
654
643
- fakeCert = fs . readFileSync ( certificatePath ) ;
655
+ fakeCert = await fs . promises . readFile ( certificatePath ) ;
644
656
645
657
this . logger . info ( `SSL certificate: ${ certificatePath } ` ) ;
646
658
}
@@ -1158,7 +1170,7 @@ class Server {
1158
1170
app . get ( "/__webpack_dev_server__/sockjs.bundle.js" , ( req , res ) => {
1159
1171
res . setHeader ( "Content-Type" , "application/javascript" ) ;
1160
1172
1161
- const { createReadStream } = require ( "graceful-fs" ) ;
1173
+ const { createReadStream } = fs ;
1162
1174
const clientPath = path . join ( __dirname , ".." , "client" ) ;
1163
1175
1164
1176
createReadStream (
@@ -2075,7 +2087,7 @@ class Server {
2075
2087
// chmod 666 (rw rw rw)
2076
2088
const READ_WRITE = 438 ;
2077
2089
2078
- fs . chmodSync ( this . options . ipc , READ_WRITE ) ;
2090
+ await fs . promises . chmod ( this . options . ipc , READ_WRITE ) ;
2079
2091
}
2080
2092
2081
2093
if ( this . options . webSocketServer ) {
0 commit comments