Permalink
Browse files

added nullstream.js to mock /dev/null on windows

  • Loading branch information...
stammen committed Nov 21, 2012
1 parent 92868a9 commit 5d087fce5c1cd1babdb8d545bbc77971b16b2ca7
Showing with 32 additions and 1 deletion.
  1. +2 −1 bin/vows
  2. +30 −0 lib/utils/nullstream.js
View
@@ -5,6 +5,7 @@ var path = require('path'),
fs = require('fs'),
util = require('util'),
wildcard = require('../lib/utils/wildcard').wildcard,
+ NullStream = require('../lib/utils/nullstream').NullStream,
events = require('events');
//
@@ -191,7 +192,7 @@ if (options.supressStdout) {
var devNullStream = null;
if(process.platform === 'win32'){
- devNullStream = fs.createWriteStream('.nul');
+ devNullStream = new NullStream();
} else {
devNullStream = fs.createWriteStream('/dev/null');
}
View
@@ -0,0 +1,30 @@
+/*
+ * nullstream.js: A simple stream to have a writestream accept all data written to it
+ * Used on windows to replace writing to /dev/null
+ *
+ * (C) 2012 MSOpenTech Inc.
+ *
+ */
+var Stream = require('stream').Stream;
+
+var NullStream = function () {
+ Stream.call(this);
+ this.writable = true;
+};
+
+exports.NullStream = NullStream;
+
+// Inherit from base stream class.
+require('util').inherits(NullStream, Stream);
+
+// Extract args to `write` and emit as `data` event.
+NullStream.prototype.write = function (data) {
+ console.log('************' + data);
+ return true;
+};
+
+
+// Extract args to `end` and emit as `end` event.
+NullStream.prototype.end = function () {
+ this.emit('end');
+};

0 comments on commit 5d087fc

Please sign in to comment.