有没有办法在控制台触发之前更改所有标准输出数据?
Is there a way to change all stdout data before it fired in the console?
我需要处理发送到标准输出的所有数据。
因为 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");
我需要处理发送到标准输出的所有数据。 因为 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");