Skip to content

Commit 4a9dc5d

Browse files
committed
added nopstream to mimic writing to /dev/null on windows
1 parent 5d087fc commit 4a9dc5d

File tree

3 files changed

+26
-32
lines changed

3 files changed

+26
-32
lines changed

bin/vows

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ var path = require('path'),
55
fs = require('fs'),
66
util = require('util'),
77
wildcard = require('../lib/utils/wildcard').wildcard,
8-
NullStream = require('../lib/utils/nullstream').NullStream,
8+
NopStream = require('../lib/utils/nopstream').NopStream,
99
events = require('events');
1010

1111
//
@@ -192,7 +192,7 @@ if (options.supressStdout) {
192192
var devNullStream = null;
193193

194194
if(process.platform === 'win32'){
195-
devNullStream = new NullStream();
195+
devNullStream = new NopStream ();
196196
} else {
197197
devNullStream = fs.createWriteStream('/dev/null');
198198
}

lib/utils/nopstream.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// NopStream
2+
// a writeable stream to mimic writing to /dev/null on windows
3+
// from https://gist.github.com/3221453
4+
5+
// Set both readable and writable in constructor.
6+
var NopStream = exports.NopStream = function () {
7+
this.readable = true;
8+
this.writable = true;
9+
};
10+
11+
// Inherit from base stream class.
12+
require('util').inherits(NopStream , require('stream'));
13+
14+
// Extract args to `write` and emit as `data` event.
15+
NopStream .prototype.write = function () {
16+
args = Array.prototype.slice.call(arguments, 0);
17+
this.emit.apply(this, ['data'].concat(args))
18+
};
19+
20+
// Extract args to `end` and emit as `end` event.
21+
NopStream .prototype.end = function () {
22+
args = Array.prototype.slice.call(arguments, 0);
23+
this.emit.apply(this, ['end'].concat(args))
24+
};

lib/utils/nullstream.js

Lines changed: 0 additions & 30 deletions
This file was deleted.

0 commit comments

Comments
 (0)