Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

added nopstream to mimic writing to /dev/null on windows

  • Loading branch information...
commit 4a9dc5dbef6298bab68849cb9c088973527a4f53 1 parent 5d087fc
Dale Stammen stammen authored
Showing with 26 additions and 32 deletions.
  1. +2 −2 bin/vows
  2. +24 −0 lib/utils/nopstream.js
  3. +0 −30 lib/utils/nullstream.js
4 bin/vows
View
@@ -5,7 +5,7 @@ var path = require('path'),
fs = require('fs'),
util = require('util'),
wildcard = require('../lib/utils/wildcard').wildcard,
- NullStream = require('../lib/utils/nullstream').NullStream,
+ NopStream = require('../lib/utils/nopstream').NopStream,
events = require('events');
//
@@ -192,7 +192,7 @@ if (options.supressStdout) {
var devNullStream = null;
if(process.platform === 'win32'){
- devNullStream = new NullStream();
+ devNullStream = new NopStream ();
} else {
devNullStream = fs.createWriteStream('/dev/null');
}
24 lib/utils/nopstream.js
View
@@ -0,0 +1,24 @@
+// NopStream
+// a writeable stream to mimic writing to /dev/null on windows
+// from https://gist.github.com/3221453
+
+// Set both readable and writable in constructor.
+var NopStream = exports.NopStream = function () {
+ this.readable = true;
+ this.writable = true;
+};
+
+// Inherit from base stream class.
+require('util').inherits(NopStream , require('stream'));
+
+// Extract args to `write` and emit as `data` event.
+NopStream .prototype.write = function () {
+ args = Array.prototype.slice.call(arguments, 0);
+ this.emit.apply(this, ['data'].concat(args))
+};
+
+// Extract args to `end` and emit as `end` event.
+NopStream .prototype.end = function () {
+ args = Array.prototype.slice.call(arguments, 0);
+ this.emit.apply(this, ['end'].concat(args))
+};
30 lib/utils/nullstream.js
View
@@ -1,30 +0,0 @@
-/*
- * 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');
-};
Please sign in to comment.
Something went wrong with that request. Please try again.