有没有办法在控制台中触发之前更改所有标准输出数据?



我需要操作发送到标准输出的所有数据。 因为SDTOUT是我尝试做的流

process.stdout.on('data', chunk => {
//change chunk and return it
});

但这无济

于事。有什么建议吗?

看看 https://www.npmjs.com/package/intercept-stdout

您可以使用此模块挂接到标准输出:

var intercept = require("intercept-stdout");
var unhook_intercept = intercept(function(txt) {
return txt.replace( /this/i , 'that' );
});
console.log("This text is being modified");
// Stop intercepting stdout
unhook_intercept();
console.log("This text is _not_ being modified");

最新更新