Skip to content

Commit 92e7ee6

Browse files
committed
[fix] Correct weird log output and correct silent usage. Fixes http-party#181.
1 parent 5e014e8 commit 92e7ee6

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

bin/http-server

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ var port = argv.p || parseInt(process.env.PORT, 10),
4545
host = argv.a || '0.0.0.0',
4646
ssl = !!argv.S || !!argv.ssl,
4747
proxy = argv.P || argv.proxy,
48-
logger = colors && {};
48+
logger;
4949

5050
if (!argv.s && !argv.silent) {
5151
logger = {
@@ -69,6 +69,12 @@ if (!argv.s && !argv.silent) {
6969
}
7070
};
7171
}
72+
else if (colors) {
73+
logger = {
74+
info: function () {},
75+
request: function () {}
76+
};
77+
}
7278

7379
if (!port) {
7480
portfinder.basePort = 8080;
@@ -109,18 +115,16 @@ function listen(port) {
109115
var canonicalHost = host === '0.0.0.0' ? '127.0.0.1' : host,
110116
protocol = ssl ? 'https:' : 'http:';
111117

112-
logger.info('Starting up http-server, serving '.yellow
113-
+ server.root.cyan
114-
+ ssl ? ' through'.yellow + ' https'.cyan : ''
115-
+ ' on: '.yellow
116-
+ (protocol + '//' + host + ':' + port).cyan);
117-
118-
logger.info('\nAvailable on:'.yellow);
118+
logger.info(['Starting up http-server, serving '.yellow,
119+
server.root.cyan,
120+
ssl ? (' through'.yellow + ' https'.cyan) : '',
121+
'\nAvailable on:'.yellow
122+
].join(''));
119123

120124
Object.keys(ifaces).forEach(function (dev) {
121125
ifaces[dev].forEach(function (details) {
122126
if (details.family === 'IPv4') {
123-
logger.info((' http://' + details.address + ':' + port.toString()).green);
127+
logger.info((' ' + protocol + details.address + ':' + port.toString()).green);
124128
}
125129
});
126130
});

0 commit comments

Comments
 (0)