File tree Expand file tree Collapse file tree 2 files changed +14
-11
lines changed Expand file tree Collapse file tree 2 files changed +14
-11
lines changed Original file line number Diff line number Diff line change 3
3
const os = require ( "os" ) ;
4
4
const path = require ( "path" ) ;
5
5
const url = require ( "url" ) ;
6
+ const util = require ( "util" ) ;
6
7
const fs = require ( "graceful-fs" ) ;
7
8
const ipaddr = require ( "ipaddr.js" ) ;
8
9
const internalIp = require ( "internal-ip" ) ;
@@ -18,12 +19,15 @@ if (!process.env.WEBPACK_SERVE) {
18
19
class Server {
19
20
constructor ( options = { } , compiler ) {
20
21
// TODO: remove this after plugin support is published
22
+
23
+ const showDeprecationWarning = util . deprecate (
24
+ ( ) => { } ,
25
+ "Using 'compiler' as the first argument is deprecated. Please use 'options' as the first argument and 'compiler' as the second argument." ,
26
+ "DEP_WEBPACK_DEV_SERVER_API"
27
+ ) ;
28
+
21
29
if ( options . hooks ) {
22
- process . emitWarning (
23
- "Using 'compiler' as the first argument is deprecated. Please use 'options' as the first argument and 'compiler' as the second argument." ,
24
- "DeprecationWarning" ,
25
- "DEP_WEBPACK_DEV_SERVER_API"
26
- ) ;
30
+ showDeprecationWarning ( ) ;
27
31
[ options , compiler ] = [ compiler , options ] ;
28
32
}
29
33
Original file line number Diff line number Diff line change @@ -93,14 +93,13 @@ describe("Server", () => {
93
93
// TODO: remove this after plugin support is published
94
94
it ( "should create and run server with old parameters order and log deprecation warning" , ( done ) => {
95
95
const compiler = webpack ( config ) ;
96
- const processSpy = jest . spyOn ( process , "emitWarning" ) ;
96
+ const util = require ( "util" ) ;
97
+ const utilSpy = jest . spyOn ( util , "deprecate" ) ;
97
98
98
99
const server = new Server ( compiler , baseDevConfig ) ;
99
100
100
- expect ( processSpy ) . toHaveBeenCalledWith (
101
- "Using 'compiler' as the first argument is deprecated. Please use 'options' as the first argument and 'compiler' as the second argument." ,
102
- "DeprecationWarning" ,
103
- "DEP_WEBPACK_DEV_SERVER_API"
101
+ expect ( utilSpy . mock . calls [ 0 ] [ 1 ] ) . toBe (
102
+ "Using 'compiler' as the first argument is deprecated. Please use 'options' as the first argument and 'compiler' as the second argument."
104
103
) ;
105
104
106
105
compiler . hooks . done . tap ( "webpack-dev-server" , ( ) => {
@@ -117,7 +116,7 @@ describe("Server", () => {
117
116
getEntries ( server ) ;
118
117
} ) ;
119
118
120
- processSpy . mockRestore ( ) ;
119
+ utilSpy . mockRestore ( ) ;
121
120
} ) ;
122
121
} ) ;
123
122
You can’t perform that action at this time.
0 commit comments