@@ -545,11 +545,11 @@ 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 = await fs . promises . exists ( certificatePath ) ;
549
549
550
550
if ( certificateExists ) {
551
551
const certificateTtl = 1000 * 60 * 60 * 24 ;
552
- const certificateStat = fs . statSync ( certificatePath ) ;
552
+ const certificateStat = await fs . promises . stat ( certificatePath ) ;
553
553
554
554
const now = new Date ( ) ;
555
555
@@ -634,34 +634,18 @@ class Server {
634
634
] ,
635
635
} ) ;
636
636
637
- await fs . mkdir ( certificateDir , { recursive : true } , ( error ) => {
638
- if ( error ) {
639
- this . logger . error ( error ) ;
640
- }
641
- } ) ;
637
+ await fs . promises . mkdir ( certificateDir , { recursive : true } ) ;
642
638
643
- await fs . writeFile (
639
+ await fs . promises . writeFile (
644
640
certificatePath ,
645
641
pems . private + pems . cert ,
646
642
{
647
643
encoding : "utf8" ,
648
- } ,
649
- ( error ) => {
650
- if ( error ) {
651
- this . logger . error ( error ) ;
652
- }
653
644
}
654
645
) ;
655
646
}
656
647
657
- fakeCert = await new Promise ( ( resolve , reject ) => {
658
- fs . readFile ( certificatePath , ( error , data ) => {
659
- if ( error ) {
660
- reject ( error ) ;
661
- }
662
- resolve ( data ) ;
663
- } ) ;
664
- } ) ;
648
+ fakeCert = await fs . promises . readFile ( certificatePath ) ;
665
649
666
650
this . logger . info ( `SSL certificate: ${ certificatePath } ` ) ;
667
651
}
@@ -1179,7 +1163,7 @@ class Server {
1179
1163
app . get ( "/__webpack_dev_server__/sockjs.bundle.js" , ( req , res ) => {
1180
1164
res . setHeader ( "Content-Type" , "application/javascript" ) ;
1181
1165
1182
- const { createReadStream } = require ( "graceful-fs" ) ;
1166
+ const { createReadStream } = fs ;
1183
1167
const clientPath = path . join ( __dirname , ".." , "client" ) ;
1184
1168
1185
1169
createReadStream (
@@ -2054,10 +2038,10 @@ class Server {
2054
2038
const net = require ( "net" ) ;
2055
2039
const socket = new net . Socket ( ) ;
2056
2040
2057
- socket . on ( "error" , ( error ) => {
2041
+ socket . on ( "error" , async ( error ) => {
2058
2042
if ( error . code === "ECONNREFUSED" ) {
2059
2043
// No other server listening on this socket so it can be safely removed
2060
- fs . unlinkSync ( this . options . ipc ) ;
2044
+ await fs . promises . unlink ( this . options . ipc ) ;
2061
2045
2062
2046
resolve ( ) ;
2063
2047
@@ -2096,11 +2080,7 @@ class Server {
2096
2080
// chmod 666 (rw rw rw)
2097
2081
const READ_WRITE = 438 ;
2098
2082
2099
- await fs . chmod ( this . options . ipc , READ_WRITE , ( error ) => {
2100
- if ( error ) {
2101
- this . logger . error ( error ) ;
2102
- }
2103
- } ) ;
2083
+ await fs . promises . chmod ( this . options . ipc , READ_WRITE ) ;
2104
2084
}
2105
2085
2106
2086
if ( this . options . webSocketServer ) {
0 commit comments