1
0
Fork 0
forked from svrjs/svrjs

Add an inspector condition to disabling stdout

This commit is contained in:
Dorian Niemiec 2024-04-27 06:01:09 +02:00
parent 3839f4d1df
commit 9eb982dc92

10
svr.js
View file

@ -390,6 +390,12 @@ try {
} catch (err) {
// Don't use hexstrbase64
}
var inspector = undefined;
try {
inspector = require("inspector");
} catch (err) {
// Don't use inspector
}
var zlib = require("zlib");
var tar = undefined;
try {
@ -934,8 +940,8 @@ function calculateNetworkIPv4FromCidr(ipWithCidr) {
}).join(".");
}
if (!process.stdout.isTTY) {
// When stdout is not a terminal, disable it to improve performance of SVR.JS
if (!process.stdout.isTTY && (!inspector || !inspector.url())) {
// When stdout is not a terminal and not attached to an Node.JS inspector, disable it to improve performance of SVR.JS
console.log = function () {};
process.stdout.write = function () {};
process.stdout._write = function () {};