|
71 | 71 | }; |
72 | 72 |
|
73 | 73 | startup.globalConsole = function() { |
74 | | - global.__defineGetter__('console', function() { |
75 | | - return NativeModule.require('console'); |
76 | | - }); |
| 74 | + global.console = NativeModule.require('console'); |
77 | 75 | }; |
78 | 76 |
|
79 | | - |
80 | 77 | startup._lazyConstants = null; |
81 | 78 |
|
82 | 79 | startup.lazyConstants = function() { |
|
126 | 123 | }; |
127 | 124 |
|
128 | 125 | startup.processStdio = function() { |
129 | | - var stdout, stdin; |
130 | | - |
131 | | - process.__defineGetter__('stdout', function() { |
132 | | - if (stdout) return stdout; |
133 | | - |
134 | | - var binding = process.binding('stdio'), |
135 | | - net = NativeModule.require('net'), |
136 | | - fs = NativeModule.require('fs'), |
137 | | - tty = NativeModule.require('tty'), |
138 | | - fd = binding.stdoutFD; |
139 | | - |
140 | | - if (binding.isatty(fd)) { |
141 | | - stdout = new tty.WriteStream(fd); |
142 | | - } else if (binding.isStdoutBlocking()) { |
143 | | - stdout = new fs.WriteStream(null, {fd: fd}); |
144 | | - } else { |
145 | | - stdout = new net.Stream(fd); |
146 | | - // FIXME Should probably have an option in net.Stream to create a |
147 | | - // stream from an existing fd which is writable only. But for now |
148 | | - // we'll just add this hack and set the `readable` member to false. |
149 | | - // Test: ./node test/fixtures/echo.js < /etc/passwd |
150 | | - stdout.readable = false; |
151 | | - } |
| 126 | + var binding = process.binding('stdio'), |
| 127 | + net = NativeModule.require('net'), |
| 128 | + fs = NativeModule.require('fs'), |
| 129 | + tty = NativeModule.require('tty'); |
| 130 | + |
| 131 | + // process.stdout |
| 132 | + |
| 133 | + var fd = binding.stdoutFD; |
| 134 | + |
| 135 | + if (binding.isatty(fd)) { |
| 136 | + process.stdout = new tty.WriteStream(fd); |
| 137 | + } else if (binding.isStdoutBlocking()) { |
| 138 | + process.stdout = new fs.WriteStream(null, {fd: fd}); |
| 139 | + } else { |
| 140 | + process.stdout = new net.Stream(fd); |
| 141 | + // FIXME Should probably have an option in net.Stream to create a |
| 142 | + // stream from an existing fd which is writable only. But for now |
| 143 | + // we'll just add this hack and set the `readable` member to false. |
| 144 | + // Test: ./node test/fixtures/echo.js < /etc/passwd |
| 145 | + process.stdout.readable = false; |
| 146 | + } |
152 | 147 |
|
153 | | - return stdout; |
154 | | - }); |
| 148 | + // process.stderr |
155 | 149 |
|
156 | 150 | var events = NativeModule.require('events'); |
157 | 151 | var stderr = process.stderr = new events.EventEmitter(); |
|
160 | 154 | stderr.write = process.binding('stdio').writeError; |
161 | 155 | stderr.end = stderr.destroy = stderr.destroySoon = function() { }; |
162 | 156 |
|
163 | | - process.__defineGetter__('stdin', function() { |
164 | | - if (stdin) return stdin; |
| 157 | + // process.stdin |
165 | 158 |
|
166 | | - var binding = process.binding('stdio'), |
167 | | - net = NativeModule.require('net'), |
168 | | - fs = NativeModule.require('fs'), |
169 | | - tty = NativeModule.require('tty'), |
170 | | - fd = binding.openStdin(); |
| 159 | + var fd = binding.openStdin(); |
171 | 160 |
|
172 | | - if (binding.isatty(fd)) { |
173 | | - stdin = new tty.ReadStream(fd); |
174 | | - } else if (binding.isStdinBlocking()) { |
175 | | - stdin = new fs.ReadStream(null, {fd: fd}); |
176 | | - } else { |
177 | | - stdin = new net.Stream(fd); |
178 | | - stdin.readable = true; |
179 | | - } |
180 | | - |
181 | | - return stdin; |
182 | | - }); |
| 161 | + if (binding.isatty(fd)) { |
| 162 | + process.stdin = new tty.ReadStream(fd); |
| 163 | + } else if (binding.isStdinBlocking()) { |
| 164 | + process.stdin = new fs.ReadStream(null, {fd: fd}); |
| 165 | + } else { |
| 166 | + process.stdin = new net.Stream(fd); |
| 167 | + process.stdin.readable = true; |
| 168 | + } |
183 | 169 |
|
184 | 170 | process.openStdin = function() { |
185 | 171 | process.stdin.resume(); |
|
0 commit comments