Skip to content

Commit 00344fd

Browse files
committed
refactor: code
1 parent 8b8e042 commit 00344fd

File tree

1 file changed

+17
-21
lines changed

1 file changed

+17
-21
lines changed

lib/Server.js

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -538,26 +538,6 @@ class Server {
538538
});
539539
}
540540

541-
runBonjour() {
542-
const bonjour = require('bonjour')();
543-
const os = require('os');
544-
const { https, port } = this.options;
545-
546-
bonjour.publish({
547-
name: `Webpack Dev Server ${os.hostname()}:${port}`,
548-
port,
549-
type: https ? 'https' : 'http',
550-
subtypes: ['webpack'],
551-
...this.options.bonjour,
552-
});
553-
554-
process.on('exit', () => {
555-
bonjour.unpublishAll(() => {
556-
bonjour.destroy();
557-
});
558-
});
559-
}
560-
561541
openBrowser(uri, options) {
562542
const isAbsoluteUrl = require('is-absolute-url');
563543
const open = require('open');
@@ -825,7 +805,23 @@ class Server {
825805
}
826806

827807
if (this.options.bonjour) {
828-
this.runBonjour();
808+
const bonjour = require('bonjour')();
809+
const os = require('os');
810+
const { https, port } = this.options;
811+
812+
bonjour.publish({
813+
name: `Webpack Dev Server ${os.hostname()}:${port}`,
814+
port,
815+
type: https ? 'https' : 'http',
816+
subtypes: ['webpack'],
817+
...this.options.bonjour,
818+
});
819+
820+
process.on('exit', () => {
821+
bonjour.unpublishAll(() => {
822+
bonjour.destroy();
823+
});
824+
});
829825
}
830826

831827
this.logStatus();

0 commit comments

Comments
 (0)