Skip to content

Commit

Permalink
added nullstream.js to mock /dev/null on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
stammen committed Nov 21, 2012
1 parent 92868a9 commit 5d087fc
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
3 changes: 2 additions & 1 deletion bin/vows
Original file line number Diff line number Diff line change
Expand Up @@ -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');

//
Expand Down Expand Up @@ -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');
}
Expand Down
30 changes: 30 additions & 0 deletions lib/utils/nullstream.js
Original file line number Diff line number Diff line change
@@ -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.