Skip to content

Commit 145d4e5

Browse files
committed
feat(server): 由显示所有本机 ip 改为只显示 127.0.0.1
1 parent a4a93de commit 145d4e5

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

lib/commands/server.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -332,14 +332,13 @@ exports.run = function (options) {
332332
});
333333
server.listen(port, function () {
334334
log('Starting up server, serving at: ' + options.cwd);
335-
log('Available on:');
336335

337336
var networkInterfaces = os.networkInterfaces();
338337
var protocol = options.https ? 'https://' : 'http://';
339338
Object.keys(networkInterfaces).forEach(function (dev) {
340339
networkInterfaces[dev].forEach(function (details) {
341-
if (details.family === 'IPv4') {
342-
details.address.indexOf('127.0.0.1') > -1 ? info(' ' + (protocol + details.address + ':' + port).underline) : info(' ' + protocol + details.address + ':' + port);
340+
if (details.family === 'IPv4' && details.address.indexOf('127.0.0.1') > -1) {
341+
log('Available on: ' + (protocol + details.address + ':' + port).underline);
343342
}
344343
});
345344
});

src/commands/server.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -321,16 +321,13 @@ exports.run = (options) => {
321321
})
322322
server.listen(port, () => {
323323
log('Starting up server, serving at: ' + options.cwd)
324-
log('Available on:')
325324

326325
let networkInterfaces = os.networkInterfaces();
327326
let protocol = options.https ? 'https://' : 'http://';
328327
Object.keys(networkInterfaces).forEach(function (dev) {
329328
networkInterfaces[dev].forEach(function (details) {
330-
if (details.family === 'IPv4') {
331-
details.address.indexOf('127.0.0.1') > -1
332-
? info(' ' + (protocol + details.address + ':' + port).underline)
333-
: info((' ' + protocol + details.address + ':' + port))
329+
if (details.family === 'IPv4' && details.address.indexOf('127.0.0.1') > -1) {
330+
log('Available on: ' + (protocol + details.address + ':' + port).underline)
334331
}
335332
});
336333
});

0 commit comments

Comments
 (0)