nodejs-vows/nodejs-vows-supress-stdout.patch

51 lines
1.6 KiB
Diff
Raw Normal View History

2020-08-20 09:33:54 +08:00
commit ff30573e563482a509d5509e1944fda888b3fb16
Author: Tom Hughes <tom@compton.nu>
Date: Thu Mar 15 18:47:09 2018 +0000
Fix stdout redirection for Node 8.x
Replacing the stdout property on process no longer seems to
work fully as console.log still seems to get to the real output
stream somehow, so try an alternative approach.
diff --git a/bin/vows b/bin/vows
index ffc6576..4bd8eb6 100755
--- a/bin/vows
+++ b/bin/vows
@@ -6,7 +6,8 @@ var path = require('path'),
util = require('util'),
glob = require('glob'),
NopStream = require('../lib/utils/nopstream').NopStream,
- events = require('events');
+ events = require('events'),
+ stream = require('stream');
//
// Attempt to load Coffee-Script. If it's not available, continue on our
@@ -189,18 +190,15 @@ if (options.nocolor) {
}
if (options.supressStdout) {
- _reporter.setStream && _reporter.setStream(process.stdout);
- var devNullStream = null;
+ stdout_write = process.stdout.write;
- if(process.platform === 'win32'){
- devNullStream = new NopStream ();
- } else {
- devNullStream = fs.createWriteStream('/dev/null');
- }
+ _reporter.setStream && _reporter.setStream(new stream.Writable({
+ write: function yyy(chunk, encoding, callback) {
+ stdout_write.call(process.stdout, chunk, encoding, callback);
+ }
+ }));
- process.__defineGetter__('stdout', function () {
- return devNullStream;
- });
+ process.stdout.write = function xxx(chunk, encoding, callback) {}
}
if (options.watch) {