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'),
stream = require('stream'),
util = require('util');
stream,
util = require('util'),
semver = require('semver');
if (semver.satisfies(process.version, '>=0.10.0')) {
stream = require('stream');
} else {
stream = require('readable-stream');
}
var 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) {
debug("closing the underlying stream");
this.theStream.end(null, null, cb);
this.theStream.end(cb);
};
BaseRollingFileStream.prototype.shouldRoll = function() {

View File

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

View File

@ -1,10 +1,18 @@
var vows = require('vows')
, assert = require('assert')
, streams = require('stream')
, fs = require('fs')
, DateRollingFileStream = require('../../lib/streams').DateRollingFileStream
, semver = require('semver')
, streams
, DateRollingFileStream
, 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) {
return function() {
fs.unlink(filename);

View File

@ -3,8 +3,16 @@ var vows = require('vows')
, assert = require('assert')
, events = require('events')
, fs = require('fs')
, streams = require('stream')
, RollingFileStream = require('../../lib/streams').RollingFileStream;
, semver = require('semver')
, 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) {
try {