backporting new streams to node 0.8 for issue #129

This commit is contained in:
Gareth Jones 2013-04-11 21:45:16 +10:00
parent 36c5175a55
commit ed7462885f
4 changed files with 33 additions and 8 deletions

View File

@ -1,6 +1,13 @@
var fs = require('fs'), var fs = require('fs'),
stream = require('stream'), stream,
util = require('util'); util = require('util'),
semver = require('semver');
if (semver.satisfies(process.version, '>=0.10.0')) {
stream = require('stream');
} else {
stream = require('readable-stream');
}
var debug; var debug;
if (process.env.NODE_DEBUG && /\blog4js\b/.test(process.env.NODE_DEBUG)) { if (process.env.NODE_DEBUG && /\blog4js\b/.test(process.env.NODE_DEBUG)) {
@ -69,7 +76,7 @@ BaseRollingFileStream.prototype.openTheStream = function(cb) {
BaseRollingFileStream.prototype.closeTheStream = function(cb) { BaseRollingFileStream.prototype.closeTheStream = function(cb) {
debug("closing the underlying stream"); debug("closing the underlying stream");
this.theStream.end(null, null, cb); this.theStream.end(cb);
}; };
BaseRollingFileStream.prototype.shouldRoll = function() { BaseRollingFileStream.prototype.shouldRoll = function() {

View File

@ -29,7 +29,9 @@
}, },
"dependencies": { "dependencies": {
"async": "0.1.15", "async": "0.1.15",
"dequeue": "1.0.3" "dequeue": "1.0.3",
"semver": "~1.1.4",
"readable-stream": "~1.0.2"
}, },
"devDependencies": { "devDependencies": {
"vows": "0.7.0", "vows": "0.7.0",

View File

@ -1,10 +1,18 @@
var vows = require('vows') var vows = require('vows')
, assert = require('assert') , assert = require('assert')
, streams = require('stream')
, fs = require('fs') , fs = require('fs')
, DateRollingFileStream = require('../../lib/streams').DateRollingFileStream , semver = require('semver')
, streams
, DateRollingFileStream
, testTime = new Date(2012, 8, 12, 10, 37, 11); , testTime = new Date(2012, 8, 12, 10, 37, 11);
if (semver.satisfies(process.version, '>=0.10.0')) {
streams = require('stream');
} else {
streams = require('readable-stream');
}
DateRollingFileStream = require('../../lib/streams').DateRollingFileStream
function cleanUp(filename) { function cleanUp(filename) {
return function() { return function() {
fs.unlink(filename); fs.unlink(filename);

View File

@ -3,8 +3,16 @@ var vows = require('vows')
, assert = require('assert') , assert = require('assert')
, events = require('events') , events = require('events')
, fs = require('fs') , fs = require('fs')
, streams = require('stream') , semver = require('semver')
, RollingFileStream = require('../../lib/streams').RollingFileStream; , streams
, RollingFileStream;
if (semver.satisfies(process.version, '>=0.10.0')) {
streams = require('stream');
} else {
streams = require('readable-stream');
}
RollingFileStream = require('../../lib/streams').RollingFileStream;
function remove(filename) { function remove(filename) {
try { try {