node/test/fixtures/stdio-filter.js

12 lines
292 B
JavaScript
Raw Normal View History

var util = require('util');
var regexIn = process.argv[2];
var replacement = process.argv[3];
var re = new RegExp(regexIn, 'g');
var stdin = process.openStdin();
2010-12-03 09:03:18 +08:00
stdin.addListener('data', function(data) {
data = data.toString();
process.stdout.write(data.replace(re, replacement));
});