From b2811710303bfaac92087b02b278a6effae39e4a Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Thu, 15 Sep 2011 13:57:41 -0700 Subject: [PATCH] Support legacy API: process.stdout.fd --- src/node.js | 9 +++++++++ test/simple/test-console.js | 3 +++ 2 files changed, 12 insertions(+) diff --git a/src/node.js b/src/node.js index f42bff5f32..6b67d3406d 100644 --- a/src/node.js +++ b/src/node.js @@ -251,6 +251,9 @@ stdout._type = "pipe"; } + // For supporting legacy API we put the FD here. + stdout.fd = fd; + return stdout; }); @@ -259,6 +262,9 @@ stderr.readable = false; stderr.write = process.binding('stdio').writeError; stderr.end = stderr.destroy = stderr.destroySoon = function() { }; + // For supporting legacy API we put the FD here. + // XXX this could break things if anyone ever closes this stream? + stderr.fd = 2; process.__defineGetter__('stdin', function() { if (stdin) return stdin; @@ -278,6 +284,9 @@ stdin.readable = true; } + // For supporting legacy API we put the FD here. + stdin.fd = fd; + return stdin; }); diff --git a/test/simple/test-console.js b/test/simple/test-console.js index 39d11d16e7..8cdf36b14b 100644 --- a/test/simple/test-console.js +++ b/test/simple/test-console.js @@ -27,6 +27,9 @@ var assert = require('assert'); assert.ok(process.stdout.writable); assert.ok(process.stderr.writable); +// Support legacy API +assert.equal('number', typeof process.stdout.fd); +assert.equal('number', typeof process.stderr.fd); var stdout_write = global.process.stdout.write;