xshell 1.0.31 → 1.0.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/server.d.ts +1 -0
- package/server.js +8 -4
package/package.json
CHANGED
package/server.d.ts
CHANGED
package/server.js
CHANGED
|
@@ -2,6 +2,7 @@ import { createServer as http_create_server } from 'http';
|
|
|
2
2
|
import zlib from 'zlib';
|
|
3
3
|
import { createReadStream } from 'fs';
|
|
4
4
|
import { Readable } from 'stream';
|
|
5
|
+
import util from 'util';
|
|
5
6
|
// --- 3rd party
|
|
6
7
|
import upath from 'upath';
|
|
7
8
|
import qs from 'qs';
|
|
@@ -33,6 +34,7 @@ export class Server {
|
|
|
33
34
|
server_http;
|
|
34
35
|
server_ws;
|
|
35
36
|
remote;
|
|
37
|
+
colors = util.inspect.defaultOptions.colors;
|
|
36
38
|
constructor({ port, remote } = {}) {
|
|
37
39
|
if (port !== undefined)
|
|
38
40
|
this.port = port;
|
|
@@ -162,6 +164,7 @@ export class Server {
|
|
|
162
164
|
return false;
|
|
163
165
|
}
|
|
164
166
|
logger(ctx) {
|
|
167
|
+
const { colors } = this;
|
|
165
168
|
const { request } = ctx;
|
|
166
169
|
const { query, body, path, _path, protocol, host, req: { httpVersion: http_version }, ip, } = request;
|
|
167
170
|
let { method } = request;
|
|
@@ -179,7 +182,7 @@ export class Server {
|
|
|
179
182
|
if (ua.isDesktop)
|
|
180
183
|
t += 'desktop';
|
|
181
184
|
if (ua.isBot)
|
|
182
|
-
t += `${t ? ' ' : ''}${'robot'.blue}`;
|
|
185
|
+
t += `${t ? ' ' : ''}${colors ? 'robot'.blue : 'robot'}`;
|
|
183
186
|
if (ua.platform !== 'unknown' && !ua.os.startsWith('Windows'))
|
|
184
187
|
t += '/' + ua.platform.toLowerCase().replace('apple mac', 'mac');
|
|
185
188
|
if (ua.os !== 'unknown' && ua.platform !== 'Android')
|
|
@@ -196,7 +199,7 @@ export class Server {
|
|
|
196
199
|
s += `${`${protocol.pad(5)}/${http_version}`.pad(10)} `;
|
|
197
200
|
// --- method
|
|
198
201
|
method = method.toLowerCase();
|
|
199
|
-
s += method === 'get' ? method.pad(10) : method.pad(10).yellow;
|
|
202
|
+
s += (method === 'get' || !colors) ? method.pad(10) : method.pad(10).yellow;
|
|
200
203
|
// --- host
|
|
201
204
|
s += `${host.pad(20)} `;
|
|
202
205
|
// --- path
|
|
@@ -204,7 +207,7 @@ export class Server {
|
|
|
204
207
|
if (path.toLowerCase() !== _path.toLowerCase())
|
|
205
208
|
return `${_path.blue} → ${path}`;
|
|
206
209
|
if (!path.includes('.'))
|
|
207
|
-
return path.yellow;
|
|
210
|
+
return colors ? path.yellow : path;
|
|
208
211
|
return path;
|
|
209
212
|
})();
|
|
210
213
|
// --- query
|
|
@@ -241,7 +244,8 @@ export class Server {
|
|
|
241
244
|
response.body = Readable.fromWeb(response_.body);
|
|
242
245
|
}
|
|
243
246
|
catch (error) {
|
|
244
|
-
|
|
247
|
+
if (error.status !== 404)
|
|
248
|
+
console.log(error);
|
|
245
249
|
if (error.response) {
|
|
246
250
|
const { status, headers, text } = error.response;
|
|
247
251
|
response.status = status;
|