File tree Expand file tree Collapse file tree 3 files changed +37
-34
lines changed Expand file tree Collapse file tree 3 files changed +37
-34
lines changed Original file line number Diff line number Diff line change @@ -192,7 +192,19 @@ function startDevServer(config, options) {
192
192
}
193
193
} ) ;
194
194
195
- runServer ( ) ;
195
+ server . listen ( options . socket , options . host , ( err ) => {
196
+ if ( err ) {
197
+ throw err ;
198
+ }
199
+ // chmod 666 (rw rw rw)
200
+ const READ_WRITE = 438 ;
201
+
202
+ fs . chmod ( options . socket , READ_WRITE , ( err ) => {
203
+ if ( err ) {
204
+ throw err ;
205
+ }
206
+ } ) ;
207
+ } ) ;
196
208
} else if ( options . port ) {
197
209
runServer ( ) ;
198
210
} else {
Original file line number Diff line number Diff line change @@ -741,6 +741,21 @@ class Server {
741
741
return false ;
742
742
}
743
743
744
+ showStatus ( ) {
745
+ const suffix =
746
+ this . options . inline !== false || this . options . lazy === true
747
+ ? '/'
748
+ : '/webpack-dev-server/' ;
749
+ const uri = `${ createDomain ( this . options , this . listeningApp ) } ${ suffix } ` ;
750
+
751
+ status (
752
+ uri ,
753
+ this . options ,
754
+ this . log ,
755
+ this . options . stats && this . options . stats . colors
756
+ ) ;
757
+ }
758
+
744
759
// delegate listen call and init sockjs
745
760
listen ( port , hostname , fn ) {
746
761
this . hostname = hostname ;
@@ -816,36 +831,7 @@ class Server {
816
831
runBonjour ( this . options ) ;
817
832
}
818
833
819
- const showStatus = ( ) => {
820
- const suffix =
821
- this . options . inline !== false || this . options . lazy === true
822
- ? '/'
823
- : '/webpack-dev-server/' ;
824
-
825
- const uri = `${ createDomain ( this . options , this . listeningApp ) } ${ suffix } ` ;
826
-
827
- status (
828
- uri ,
829
- this . options ,
830
- this . log ,
831
- this . options . stats && this . options . stats . colors
832
- ) ;
833
- } ;
834
-
835
- if ( this . options . socket ) {
836
- // chmod 666 (rw rw rw)
837
- const READ_WRITE = 438 ;
838
-
839
- fs . chmod ( this . options . socket , READ_WRITE , ( err ) => {
840
- if ( err ) {
841
- throw err ;
842
- }
843
-
844
- showStatus ( ) ;
845
- } ) ;
846
- } else {
847
- showStatus ( ) ;
848
- }
834
+ this . showStatus ( ) ;
849
835
850
836
if ( fn ) {
851
837
fn . call ( this . listeningApp , err ) ;
Original file line number Diff line number Diff line change 3
3
/* eslint-disable
4
4
array-bracket-spacing,
5
5
*/
6
+ const { unlink } = require ( 'fs' ) ;
6
7
const path = require ( 'path' ) ;
7
8
const execa = require ( 'execa' ) ;
8
9
const runDevServer = require ( './helpers/run-webpack-dev-server' ) ;
@@ -83,11 +84,15 @@ describe('CLI', () => {
83
84
} ) ;
84
85
85
86
it ( '--socket' , ( done ) => {
86
- runDevServer ( '--socket ./webpack.sock' )
87
+ const socketPath = './webpack.sock' ;
88
+
89
+ runDevServer ( `--socket ${ socketPath } ` )
87
90
. then ( ( output ) => {
88
91
expect ( output . code ) . toEqual ( 0 ) ;
89
- expect ( output . stdout . includes ( './webpack.sock' ) ) . toBe ( true ) ;
90
- done ( ) ;
92
+ expect ( output . stdout . includes ( socketPath ) ) . toBe ( true ) ;
93
+ unlink ( socketPath , ( ) => {
94
+ done ( ) ;
95
+ } ) ;
91
96
} )
92
97
. catch ( done ) ;
93
98
} ) ;
You can’t perform that action at this time.
0 commit comments